Main Content

重用桌面测试案例用于实时测试

将桌面测试用例转换为实时

在里面Test Manager, you can reuse test cases for real-time testing by converting desktop test cases to real-time test cases. For convenience, data can be stored externally so that each test case accesses common inputs and baseline data. The overall workflow is as follows:

  1. 使用外部输入创建基线,等效性或仿真测试用例。对于基线测试,请添加来自外部文件的基线数据。

  2. 在测试管理器中,在Test Browser

  3. 复制测试用例。右键单击测试案例并选择Copy

  4. Paste the new test case into a test suite.

  5. 重命名新测试用例。

  6. 右键单击新的测试案例,然后选择转换成>实时测试。对于等效测试,选择要实时运行的模拟(模拟1或模拟2)。

  7. 选择the目标计算机and加载应用程序选项。

  8. 确保模型设置与实时测试执行兼容。有关更多信息,请参阅开发计算机要求(Simulink Real-Time)

Use External Data for Real-Time Tests

您可以通过在外部垫子或Excel中定义输入数据来简化测试输入数据管理®文件。将数据映射到模型中的Inports或用于桌面模拟的测试线束。当您将桌面仿真测试用例转换为实时测试时,测试案例使用相同的计入映射。

Using external data depends on how your test case loads the real-time application:

从模型加载实时应用程序

如果您正在使用外部数据进行实时测试,请从模型加载实时应用程序,可将您选择使用Excel文件,MAT文件或CSV文件。外部数据已内置在应用程序中,您可以从目标应用程序或目标计算机重新运行应用程序。

在里面测试系统section, set the application to load fromModel。在里面输入测试案例的部分,单击添加,然后选择一个Excel文件,垫子文件或CSV文件。将数据映射到您的模型中。有关输入映射的更多信息,请参阅在测试用例中使用外部Excel或Mat-File数据

Load Real-Time Application from Target Application or Target Computer

从模型中运行测试后,您可以从目标应用程序或目标计算机进行测试而无需重新编译。该应用程序使用从模型进行测试时的输入映射。

您可以将外部数据映射到从目标应用程序或目标计算机上加载的测试用例,而无需先从模型运行。外部数据必须在垫子文件中,如果从模型加载测试,则使用相同的格式使用。在里面测试系统部分,选择从Target Applicationor目标计算机。在里面输入部分,单击添加并选择a MAT file. The Input string is not editable.

重用桌面测试案例进行实时测试

此示例使用Excel文件中定义的外部输入数据显示了基本的桌面测试案例重用工作流。您在桌面上运行基线测试用例,更新基线数据,将测试用例的副本转换为实时测试,然后在目标计算机上运行测试用例。提供了测试文件,基线数据和Excel输入数据文件。此示例仅在Windows系统上运行。

Open the Test Manager and Test File

The test file runs a transmission shift controller algorithm through four iterations, each corresponding to a different test scenario: passing, gradual acceleration, hard braking, and coasting. Baseline data associated with each scenario for the signalsvehicle speedand输出扭矩

tf = sltest.testmanager.testfile('sltestTestCaseRealTimeReuseExample.mldatx');sltest.testmanager.load(tf.name);sltest.testmanager.view;

运行基线测试和查看结果

点击在工具栏中。

测试完成时,选择输出扭矩在下面Baseline Criteria Resultto view the comparison. The Passing result fails due to transient signals that fall outside the relative tolerance.

Update the Baseline

Assume that the transient signals are not significant, and update the baseline data:

  1. 点击Next Failure。The first failure region is bounded by data cursors.

  2. 点击Update Baseline > Replace Signal Segment in Baseline File从工具条中,并确认您要覆盖数据。

  3. 重复其他两个故障区域的过程。

将基线测试转换为实时测试

  1. 在测试浏览器中,右键单击基线测试并选择Copy

  2. 在测试套件下粘贴新测试用例。

  3. Rename the new test caseRT Baseline Test

  4. Right-clickRT Baseline Test并选择转换成>实时测试

跑过实时测试Case

  1. 设置目标计算机

  2. 将测试系统设置为从Model

  3. 跑过RT Baseline Test测试用例。

检查并解决测试失败

在这个例子中,由于失败的几个场景to timing impacts on the data output. For example, in the硬盘iteration, thevehicle speed施加制动器后,输出落在相对公差之外。为了解决此失败,您可以:

  • Increase the relative tolerance for the real-time test.

  • Create a separate set of baseline data for the real-time test.

Related Topics