Main Content

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.

  1. To open the model, type openExample('sldemo_absbrake').

  2. Add the Check Static Upper Bound block from the Model Verification library to the model.

  3. Connect the Check Static Upper Bound block to the Sd signal.

    Anti-Lock Braking System model

  4. In the Check Static Upper Bound block dialog box, and set Upper bound to 725.

Create the Test Case

  1. 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.

  2. 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.

  3. Select New > Test Case > Simulation Test.

  4. Right-click the new simulation test case in the Test Browser pane, and select Rename. Rename the test case to Upper Bound Test.

  5. In the test case, under System Under Test, click the Use current model button to assign the sldemo_absbrake model to the test case.

  6. Under Parameter Overrides, click Add to add a parameter set.

  7. In the dialog box, click the Refresh button to update the model parameter list.

  8. Select the check box next to the workspace variable m. Click OK.

  9. Double-click the Override Value and enter 55.

    Parameter override section of test manager

    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

  1. In the Test Browser pane, select the Upper Bound Test case.

  2. 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.

Assertion error information for upper bound test

Related Topics