Main Content

Trace Coverage Results to Associated Test Cases

If you record aggregated coverage results for test cases in Simulink® Test™ with your model in Normal or SIL/PIL mode, the aggregated coverage report links to the test cases associated with each model element.

Prerequisites for Tracing Associated Test Cases to Coverage Results

To view associated test cases in your coverage report, you must record aggregated coverage results for at least two test cases through the Simulink Test Manager, or produce a coverage report for cumulative coverage results from the Results Explorer. For more information, see Perform Functional Testing and Analyze Test Coverage.

Note

Test case traceability and unit test aggregation for MCDC coverage are only supported for Masking Mode. Unique-cause MCDC is not supported for these features.

Aggregate Unit-Level Coverage Data into Top-Level Model Coverage

This example shows how to generate an aggregated coverage report that includes results from both integration and unit tests.

Load the Test Cases into the Simulink® Test™ Manager

The slcovTestTraceabilityExample.mldatx test data is configured to record decision coverage.

sltest.testmanager.load('slcovTestTraceabilityExample.mldatx');
sltest.testmanager.view

Run the Test Cases

From the Simulink Test Manager, select the Combined Integration and Unit Tests test suite and click Run. This test suite contains two sub-suites, Integration Tests and Unit Tests. Alternatively, run the following command:

results = sltest.testmanager.run;

Access the Coverage Report for the Integration Tests

From the Results and Artifacts pane of the Simulink Test Manager, select the results for Integration Tests. From the Aggregated Coverage Results section, click the Report button.

The coverage report for this test suite only shows coverage results for the integration tests.

View Subsystem Details

View the coverage details for the subsystem SwitchUnit2. Notice that this subsystem does not receive full coverage. The first three decision outcomes are covered by integration test run T1. The fourth decision outcome for the MPSwitch block cannot be satisfied in the integrated system.

Access the Coverage Report for the Unit Tests

From the Results and Artifacts pane of the Simulink Test Manager, select the results for Unit Tests. From the Aggregated Coverage Results section, click the Report button.

The coverage report for this test suite only shows coverage results for the unit tests of the SwitchUnit2 subsystem that were recorded by using subsystem test harnesses.

View Subsystem Details

View the coverage details for the subsystem SwitchUnit2. Notice that this subsystem does receive full coverage from the unit tests.

Locate the Combined Unit-Level and System-Level Coverage Report

From the Results and Artifacts pane of the Simulink Test Manager, select the results for Combined Integration and Unit Tests. The results show two coverage reports available--one report for the SwitchUnit2 subsystem tested by the unit tests and one report for the top-level model that incorporates results from both the unit and integration tests.

Access Aggregated Coverage Report for the Top-Level Model

When you click the Report button for the top-level model, Simulink Coverage aggregates the integration and unit tests into a system-level coverage report.

View Subsystem Details

Notice that the subsystem receives full coverage. The first three decision outcomes for the MPSwitch MultiPortSwitch block are covered by the integration test run T1. The fourth decision outcome for the MPSwitch MultiPortSwitch block is covered by unit test run U1.2.

Related Topics