You can automatically create a set of test cases and iterations that correspond to blocks and test harnesses in your model. You specify whether the test cases are baseline, equivalence, or simulation test cases. To automatically create test cases, your model must contain either or both of the following:
One Signal Editor or Signal Builder block at the top level of the model. If the block has only one scenario or signal group, a test case is created. If the block has more than one scenario or signal group, an iteration is created for each scenario or group.
Test harnesses. If a test harness contains one (and only one) Signal Editor or Signal Builder block at the top level, a test case is created for the scenario or signal group in the block. If the block has more than one scenario or signal group, an iteration is created for each scenario or group.
To automatically create test cases or iterations for your model:
In the Test Manager, select New > Test File > Test File from Model.
In the dialog box, select the model that you want to generate test cases from. The model must be on the MATLAB® path.
Select the test case type, and click Create.
Generate test cases based on model hierarchy.
This example shows how to generate test cases based on the components in your model. This example uses the model
sltestCar, which has been pre-configured with the following:
Signal Editor block at the top level of the model
Test harnesses at the top level of the model
Signal Editor block at the top level of the test harness
Open the Model and Test Manager
Execute the following code to open the model configured with different components such as Signal Editor scenarios and test harnesses.
mdl = 'sltestCar'; open_system(mdl);
Open the test manager. Enter
sltestmgr in the MATLAB command prompt.
Generate Test Cases From the Model
In the test manager, click the New arrow and select Test File from Model.
In the New Test File dialog box, click the Use current model button to specify
sltestCar as the Model.
Specify the Location of the test file.
Baseline from the Test Type dropdown. All test cases generated will be of the test type specified here.
The sltestCar_SigEditor/Inputs test case uses table iterations.
Before you run the test, you must specify the baseline criteria for each generated test case.
close_system(mdl, 0); clear mdl;