Trace Coverage Results to Requirements by Using Simulink Test and Simulink Requirements

If you run test cases in Simulink® Test™ that are linked to requirements in Simulink Requirements™, the aggregated coverage report details the requirements implemented by each model element and the tests that verify those requirements.

Prerequisites for Tracing Requirements Links

To view linked requirements details in your coverage report, you must:

This example shows how to view the links between test cases, model elements, and linked requirements in a coverage report.

Open the slreqCCProjectStart Project and Load Test Cases

  1. Open the slreqCCProjectStart project.

    slreqCCProjectStart
  2. Load the DriverSwRequest_Tests.mldatx test data suite and open the Simulink Test Manager.

    sltest.testmanager.load('DriverSwRequest_Tests.mldatx')
    sltest.testmanager.view
  3. In the Simulink Test Manager, click the DriverSwRequest_Tests test file.

  4. To enable decision coverage collection for the test case, in the right pane under Coverage Settings:

    • Select Record coverage for system under test.

    • Under Coverage Metrics, select Decision.

    • Save your changes.

  5. Run the loaded test cases.

    resultObj = sltest.testmanager.run
  6. When the test finishes, navigate to the test case results in the Test Manager. The Aggregated Coverage Results section displays the coverage for the analyzed model.

  7. Click Report to create a coverage report.

The coverage report shows requirements details for each model element, including linked requirements, which tests verify the requirements, and which runs are associated with each verification test.

The Decisions analyzed section links to the first test case that reached each decision. To see other test cases that also reached a decision, hover over the listed test case. For more information, see Trace Coverage Results to Associated Test Cases.

Related Topics