In the Test Manager, the Create Test for Component workflow wizard creates an internal test harness and test case for a single model component. Components for which you can create test harnesses include subsystems, Stateflow® charts, or Model blocks. For a full list of components supported by test harnesses, see Test Harness and Model Relationship.
In the wizard, you specify:
The model and component to test
The test inputs
The type of test to run on the component
The format in which to save test data — MAT-file or Excel®. For more information on using Excel files in the Test Manager, see Format Test Case Data in Excel.
The wizard sets parameters for a subset of test options. To specify other options, such as coverage or reports, configure the created test cases in the Test Manager. For an example that uses the wizard, see Create and Run a Back-to-Back Test
In the model that contains the component for which you want to create the test, select that component.
In Test Manager, if no test file is open, select New > Test File or Test File from Model and save the new file.
Select the test file or test suite in which you want to create the test case, and then select New > Test for Model Component. The Create Test for Component wizard opens.
On the first page of the wizard, click the Use current model button to fill in the Top Model field. Then, click the Use currently selected subsystem button to fill in the Component field. Click Next to go to the next page of the wizard.
If the component you are testing is in a Model reference, you do not need to specify the Model block as the top model. Use the name of the model that contains the Model block as the Top Model.
On the Test Inputs page, select how to obtain the test inputs.
Use component input from the top model as test input — Simulate the model and record the inputs to the component. Then, use those inputs as the inputs to the created test harness. Use this option for debugging.
Use Design Verifier to generate test input scenarios — Create test harness inputs to meet test coverage requirements using Simulink® Design Verifier™. This option appears only if Simulink Design Verifier is installed.
If the component under test is a Subsystem block, verify that Treat as atomic unit is selected in the block parameters for that subsystem.
Select test harness input source — Select how the inputs generated by the Design Verifier are applied to the test harness.
Root input ports — Create a
test harness with root input ports as the source. Map the
design verifier input file to the input ports
Signal Editor — Create a test
harness with the Signal Editor as the source that contains
input scenarios generated by the Design Verifier.
Specify inputs in the created harness — After the wizard creates the harness, open the harness in the Test Manager and manually specify the harness inputs.
On the Verification Strategy page, select how to test the component.
Use component under test output as baseline — Simulate the model and record the outputs from the components, which are used as the baseline.
Perform back-to-back testing — Compare the results of running the component in two different simulation modes. For each simulation, select the mode from the dropdown.
Define the verification logic in the created harness — After the wizard creates the harness, open the harness. Manually specify the verification logic using Test Sequence or Test Assessments in the generated harness, or logical and temporal assessments or custom criteria in the generated test case
On the Generated Test page, specify the file name and select the format in which to save the test data.
Specify the format to save the test data — Specify the type of file in which to save data.
— Saves the test inputs, outputs, and parameters
to one sheet in an Excel spreadsheet file. For tests with
multiple iterations, each iteration is in a separate sheet. For
more information on using Excel files in the Test Manager, see Format Test Case Data in Excel.
MAT — Saves inputs and outputs in
separate MAT files. For tests that use Simulink
Design Verifier, a single MAT file contains the inputs and
parameters, and the outputs are in a separate baseline
Specify the location to save the test data — Use
the default file name, which is
name> in the current working folder. Alternately, specify
the full path of the file.
Click Done to generate a test harness and test case.
If the model has an existing external harness, the wizard creates an external test harness for the component under test. If no harness or an internal harness exists, the wizard we creates an internal test harness.
The Test Manager opens with the test case in the Test Browser pane and the test
harness in the System Under Test - Harness field. The test case