With Simulink® Design Verifier™, you can generate test cases for model coverage and custom objectives. You can also measure coverage of existing requirements-based test cases and extend these test cases to increase coverage or achieve full coverage.
This tutorial explains a simplified cruise control model that controls the throttle speed. You generate test cases that satisfy condition and decision model coverage objectives and then, simulate these test cases to generate model coverage report.
Consider a simplified cruise control model that adjusts the throttle to maintain a steady speed as set by the set speed.
This cruise control model meets these requirements:
The control system is activated when the
enable signals are
condition is defined by the AND block.
When the system is activated, the Switch block passes
set speed to the PI controller. The PI controller
throttle by integrating the error term
defined by the difference
set speed - current
Throttle continues to increase or decrease until
set speed is higher or lower than
When the system is not activated, the Discrete-Time
Integrator block resets. The error term is
zero, which means the
is in reset position.
When you perform test generation analysis, Simulink Design Verifier generates test cases for the model coverage objectives associated with each model item in the model. Table lists the condition and decision coverage objectives for the associated model blocks. For more information on model coverage objectives, see Model Coverage Objectives for Test Generation and Model Objects That Receive Coverage (Simulink Coverage).
|Block||Model Coverage Objective||Generated Test Case Description|
Each input value is set to true or false independently.
|Input is set to true or false independently.|
|Test case demonstrates that the Switch passes both the input signals to output.|
The analysis results give detailed descriptions of the coverage objectives for each model item and generated test cases for all satisfied objectives. You simulate the generated test cases to measure model coverage.
Open the model sldvexSimpleCruiseControl.
On the Design Verifier tab, in the Mode section, select Test Generation.
To generate test cases, click Generate Tests.
The Results Summary window displays the results. The result indicates
14 objectives are
On the Design Verifier tab, in the Review Results gallery, click Highlight in Model. The model objectives that the software found to be satisfied are highlighted in green.
Click the Switch block. The Result Inspector window displays the summary of the satisfied decision objectives.
The summary shows that all the objectives of the Switch block are satisfied.
To view the HTML report, in the Review Results gallery, click HTML Report.
The test objective status section includes detailed descriptions of satisfied objectives for each model item and generated test case.
To view the test case for a model coverage objective, in the Result Inspector window, click View test case. The harness model and the Signal Builder block opens.
To simulate the test case, in the Signal Builder block, click the button.
The software simulates the test case and highlights the harness model. To view the coverage of the model items, point the cursor to each model object in the harness model.