reuse desktop test cases for real-凯发k8网页登录

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 the test browser.

  3. copy the test case. right-click the test case and select copy.

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

  5. rename the new test case.

  6. right-click the new test case, and select convert to > real-time test. for equivalence tests, select which simulation (simulation 1 or simulation 2) to run in real time.

  7. select the target computer and load application from options.

  8. ensure that the model settings are compatible with real-time test execution. for more information, see (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

if you are using external data for a real-time test, 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 the system under test section, set the application to load from model. in the inputs section of the test case, click add, and select an excel file, mat file, or csv file. map the data to your model inports. for more information on input mapping, see .

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 the system under test section, select to load the application from the target application or target computer. in the inputs section, click add and 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 signals vehicle speed and output torque.

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

test manager iterations for baseline test

run the baseline test and view results

click run in the toolbar.

when the test finishes running, select output torque under baseline criteria result to view the comparison. the passing result fails due to transient signals that fall outside the relative tolerance.

test results showing output torque plot and tolerance plot with spikes at 6, 14, and 15.plots

update the baseline

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

  1. click next failure. the first failure region is bounded by data cursors.

  2. click update baseline > replace signal segment in baseline file from 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-click baseline test and select copy.

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

  3. rename the new test case rt baseline test.

  4. right-click rt baseline test and select convert to > real-time test.

run the real-time test case

  1. set the target computer.

  2. set the system under test to load from model.test manager system under test setup for loading application, model name, and targer computer

  3. run the rt baseline test test case.

examine and resolve test failures

in this example, several of the scenarios fail due to timing impacts on the data output. for example, in the hardbrake iteration, the vehicle speed output 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.

test results

related topics

网站地图