Test a Simulation for Run-Time Errors
In this example, use a simulation test case with the
sldemo_absbrake
model to test for simulation run-time
errors.
Configure the Model
Configure the model to check if the stopping distance exceeds an upper bound.
To open the model, type
openExample('sldemo_absbrake')
.Add the Check Static Upper Bound block from the Model Verification library to the model.
Connect the Check Static Upper Bound block to the
Sd
signal.In the Check Static Upper Bound block dialog box, and set Upper bound to
725
.
Create the Test Case
To open the Test Manager, on the Apps tab, under Model Verification, Validation, and Test, click Simulink Test. Then, on the Tests tab, click Simulink Test Manager.
To create a test file, click New > Test File. Name and save the test file.
The new test file consists of a test suite that contains one baseline test case. They appear in the Test Browser pane.
Select New > Test Case > Simulation Test.
Right-click the new simulation test case in the Test Browser pane, and select Rename. Rename the test case to
Upper Bound Test
.In the test case, under System Under Test, click the Use current model button to assign the
sldemo_absbrake
model to the test case.Under Parameter Overrides, click Add to add a parameter set.
In the dialog box, click the Refresh button to update the model parameter list.
Select the check box next to the workspace variable
m
. Click OK.Double-click the Override Value and enter
55
.This value overrides the parameter value in the model when the simulation runs.
Note
To restore the default value of a parameter, clear the value in the Override Value column and press Enter.
Run the Test Case
In the Test Browser pane, select the
Upper Bound Test
case.In the Test Manager toolstrip, click Run. The test results appear in the Results and Artifacts pane.
View the Error
Click on the Upper Bound Test to view the run-time error.