Automatically Create a Set of Test Cases
Creating Test Cases from Model Elements
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 block at the top level of the model. If the block has only one scenario, a test case is created. If the block has more than one scenario, an iteration is created for each scenario.
Test harnesses. If a test harness contains one (and only one) Signal Editor block at the top level, a test case is created for the scenario in the block. If the block has more than one scenario, an iteration is created for each scenario.
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.
Generating Test Cases from a Model
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.
Model = 'sltestCar';
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
sltestCaras the Model.
Specify the Location of the test file.
Baselinefrom the Test Type dropdown. All test cases generated will be of the test type specified here.
The sltestCar/Inputs test case uses table iterations.
Before you run the test, you must specify the baseline criteria for each generated test case.