Main Content

runTests

Class: slreq.ReqSet
Namespace: slreq

Run test cases linked to requirement set

Since R2022a

Description

You can use runTests to run MATLAB® unit tests, Simulink tests, and Simulink® Design Verifier™ verifiables.

example

status = runTests(rs) runs the tests linked to requirements in the requirement set rs.

example

status = runTests(rs,Select=SelectValue) runs only the tests specified by SelectValue.

Input Arguments

expand all

Requirement set, specified as an slreq.ReqSet object.

Option to select tests to run, specified as:

  • "all" — Run all tests linked to requirements in the requirement set.

  • "failed" — Run only failed tests linked to requirements in the requirement set.

  • "unexecuted" — Run only unexecuted tests linked to requirements in the requirement set.

Output Arguments

expand all

Requirement set verification status summary for the requirement set after the tests are run, returned as a MATLAB structure containing these fields:

Total number of requirements in the requirement set with verification links, returned as a double.

Number of requirements in the requirement set that passed the tests associated with them, returned as a double.

Number of requirements in the requirement set that failed the tests associated with them, returned as a double.

Number of requirements in the requirement set with unexecuted tests, returned as a double.

Number of requirements justified for verification in the requirement set, returned as a double.

Number of requirements without links to verification objects in the requirement set, returned as a double.

Examples

expand all

This example shows how to run tests linked to requirements in a requirement set.

Open the ShortestPath project.

openProject("ShortestPath");

Load the shortest_path_func_reqs and shortest_path_tests_reqs requirement sets. Requirements in these requirement sets contain links to tests in graph_unit_tests.m.

funcReqs = slreq.load("shortest_path_func_reqs");
testReqs = slreq.load("shortest_path_tests_reqs");

Run the tests linked to the requirements in the shortest_path_func_reqs requirement set.

status = runTests(funcReqs)
Running graph_unit_tests
.......... ..
Done graph_unit_tests
__________
status = struct with fields:
         total: 8
        passed: 5
        failed: 0
    unexecuted: 0
     justified: 0
          none: 3

Update and get the verification status for the shortest_path_tests_reqs requirement set to see if any tests linked to requirements in that requirement set were run.

updateVerificationStatus(testReqs);
status = getVerificationStatus(testReqs)
status = struct with fields:
         total: 14
        passed: 10
        failed: 0
    unexecuted: 3
     justified: 0
          none: 1

Run only the unexecuted tests linked to the requirement set.

status = runTests(testReqs,select="unexecuted")
Running graph_unit_tests
...
Done graph_unit_tests
__________
status = struct with fields:
         total: 14
        passed: 13
        failed: 0
    unexecuted: 0
     justified: 0
          none: 1

Version History

Introduced in R2022a