Main Content

Trace Coverage Results to Requirements

If you run test cases in Simulink® Test™ that are linked to requirements in Requirements Toolbox™, 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 CruiseRequirementsExample project.

    openExample("slrequirements/CruiseRequirementsExample")
  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.

    Test Manager section titled "Aggregated Coverage Results" shows the analyzed model crs_controller/DriverSwRequest reports 95% decision coverage and 100% execution coverage.

  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.

Coverage report for the Switch block "Switch1" shows a section titled "Requirement Testing Details." This section shows the coverage results for the block are linked to a requirement titled "Enable Switch Detection" and tested by a test case titled "Enable button." The coverage table also contains links to the associated test case.

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