You can automatically create a set of test cases 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. One test case is created for each scenario or signal group in the block.
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 each scenario or signal group in the block.
To automatically create test cases 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
sltestTestManagerCreateTestsExample, which has been pre-configured with the following:
Signal Builder group in the top model
Test harnesses in the top model
Signal Builder group at the top level of a test harness
Open the Model and Test Manager
Execute the following code to open the model configured with different components such as Signal Builder groups and test harnesses.
mdl = 'sltestTestManagerCreateTestsExample'; 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
sltestTestManagerCreateTestsExample 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.
In each generated test case, you need to specify the comparison criteria, equivalence or baseline, before you run the test.
close_system(mdl, 0); clear mdl;