Main Content

Override the Simulation Mode During Test Execution

This example shows how to override the simulation mode when you run a test. You can run a test in a simulation mode without modifying the simulation mode specified in the test case or the model settings.

Open the Model

open_system("sltestCruiseControl.slx")

In this model, the simulation mode is set to normal.

Image of the model in Simulink.

Open the Test File and Run the Test Case

Open the Simulink Test Manager and load the test file.

sltest.testmanager.view
sltest.testmanager.load("sltestCruiseControlSimMode.mldatx");

In the Test Browser pane, select Simulation Mode Test Case. In the test case properties, expand the System Under Test section, then expand the Simulation Settings and Release Overrides section. This test case uses the Simulation Mode specified in the model settings.

Image of the test case in the Simulink Test Manager.

On the toolstrip, click Run. In the Results and Artifacts pane, expand the results and select Simulation Mode Test Case. Confirm that the test uses normal simulation mode.

Simulation results showing the simulation mode is normal.

Run the Test Case in a Different Simulation Mode

In the Test Browser pane, select Simulation Mode Test Case. Click the Run drop-down, and select Run Selected in > Accelerator. In the Results and Artifacts pane, expand the second set of results and select Simulation Mode Test Case. The simulation runs in accelerator mode.

Simulation results showing the simulation mode is accelerator.

In the Test Browser pane, select Simulation Mode Test Case. Under System Under Test, in the Simulation Settings and Release Overrides section, the test file is not modified and does not display unsaved changes.

Image of the test case in the Simulink Test Manager.

Clean Up

Clear and close the Test Manager. Then, close the model without saving.

sltest.testmanager.clearResults
sltest.testmanager.clear
sltest.testmanager.close
close_system("sltestCruiseControl.slx",0)

Related Topics