Main Content

本页采用了机器翻译。点击此处可查看英文原文。

在测试执行期间覆盖仿真模式

此示例显示如何在运行测试时覆盖仿真模式。您可以在仿真模式下运行测试,而无需修改测试用例或模型设置中指定的仿真模式。

打开模型

open_system("sltestCruiseControl.slx")

在该模型中,仿真模式设置为普通。

Image of the model in Simulink.

打开测试文件并运行测试用例

打开 Simulink Test 管理器并加载测试文件。

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

测试浏览器窗格中,选择仿真模式测试用例。在测试用例属性中,展开在测系统部分,然后展开仿真设置和发布覆盖部分。该测试用例使用模型设置中指定的仿真模式

Image of the test case in the Simulink Test Manager.

在工具条上,点击运行。在结果和工件窗格中,展开结果并选择仿真模式测试用例。确认测试使用普通仿真模式。

Simulation results showing the simulation mode is normal.

在不同的仿真模式下运行测试用例

测试浏览器窗格中,选择 Simulation Mode 测试用例。单击运行下拉菜单,然后选择在 > 加速器中运行所选内容。在结果和工件窗格中,展开第二组结果并选择仿真模式测试用例。仿真在加速器模式下运行。

Simulation results showing the simulation mode is accelerator.

测试浏览器窗格中,选择仿真模式测试用例。在在测系统下的仿真设置和发布覆盖部分中,测试文件未被修改,也没有显示未保存的更改。

Image of the test case in the Simulink Test Manager.

清理

清除并关闭测试管理器。然后,关闭模型而不保存。

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

相关主题