Main Content

Reuse Desktop Test Cases for Real-Time Testing

Convert Desktop Test Cases to Real-Time

In the 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. Create a baseline, equivalence, or simulation test case with external inputs. For baseline tests, add baseline data from external files.

  2. In the Test Manager, select the test case in theTest Browser.

  3. Copy the test case. Right-click the test case and selectCopy.

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

  5. Rename the new test case.

  6. Right-click the new test case, and selectConvert to>Real-Time Test. For equivalence tests, select which simulation (simulation 1 or simulation 2) to run in real time.

  7. Select theTarget ComputerandLoad Application Fromoptions.

  8. Ensure that the model settings are compatible with real-time test execution. For more information, seeDevelopment Computer Requirements(Simulink Real-Time).

Use External Data for Real-Time Tests

You can simplify test input data management by defining the input data in an external MAT or Excel®file. Map the data to root inports in your model or test harness for desktop simulation. When you convert the desktop simulation test case into a real-time test, the test case uses the same inport mapping.

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

Load Real-Time Application from Model

如果您使用的是外部数据实时测试工程师t, loading the real-time application from the model gives you the option of using an Excel file, MAT file, or CSV file. The external data is built into the application, and you can rerun the application from the target application or target computer.

In theSystem Under Testsection, set the application to load fromModel. In theInputssection of the test case, clickAdd, and select an Excel file, MAT file, or CSV file. Map the data to your model inports. For more information on input mapping, seeUse External Excel or MAT-File Data in Test Cases.

Load Real-Time Application from Target Application or Target Computer

After running the test from the model, you can run the test from the target application or target computer without recompiling. The application uses the input mapping from when the test ran from the model.

You can map external data to a test case loaded from the target application or target computer, without first running from the model. The external data must be in a MAT file, in the same format used if the test is loaded from the model. In theSystem Under Testsection, select to load the application from theTarget ApplicationorTarget Computer. In theInputssection, clickAddand select a MAT file. The Input string is not editable.

Reuse Desktop Test Case for Real-Time Testing

This example shows a basic desktop test case reuse workflow using external input data defined in an Excel file. You run the baseline test case on the desktop, update the baseline data, convert a copy of the test case to a real-time test, then run the test case on a target computer. The test file, baseline data, and Excel input data file are provided. This example runs only on Windows systems.

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 speedandoutput torque.

tf = sltest.testmanager.TestFile('sltestTestCaseRealTimeReuseExample.mldatx'); sltest.testmanager.load(tf.Name); sltest.testmanager.view;

real_time_reuse_example_test_file.png

Run the Baseline Test and View Results

ClickRunin the toolbar.

When the test finishes running, selectoutput torqueunderBaseline Criteria Resultto view the comparison. The Passing result fails due to transient signals that fall outside the relative tolerance.

rt2.png

Update the Baseline

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

  1. ClickNext Failure. The first failure region is bounded by data cursors.

  2. ClickUpdate Baseline > Replace Signal Segment in Baseline Filefrom the toolstrip, and confirm that you want to overwrite the data.

  3. Repeat this process for the other two failure regions.

Convert Baseline Test to Real-Time Test

  1. In the Test Browser, right-clickBaseline Testand selectCopy.

  2. Paste the new test case under the test suite.

  3. Rename the new test caseRT Baseline Test.

  4. Right-clickRT Baseline Testand selectConvert to > Real-Time Test.

Run the Real-Time Test Case

  1. Set theTarget Computer.

  2. Set the system under test to load fromModel.real_time_reuse_example_test_file_rtt.png

  3. Run theRT Baseline Testtest case.

检查和资源lve Test Failures

In this example, several of the scenarios fail due to timing impacts on the data output. For example, in theHardBrakeiteration, thevehicle speedoutput falls outside the relative tolerance after the brake is applied. To resolve this failure, you could:

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

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

real_time_reuse_example_rtt_result.png

Related Topics