This example uses the following simple model, which contains two Inports, one of which is a bus.
To create a SystemTest™ test harness:
From the model in Simulink®, select Tools > SystemTest > Create Test Harness.
The Create Test Harness dialog box opens.
The test that is created is named the same as the originating model with "_harness" appended by default. Notice in this example that the model name is mInports_Buses.slx and the default name of the test is mInports_Buses_harness.test. Accept the default test name or type a new name in the text field.
By default, the location is the current folder in MATLAB®. Accept the location or use the Browse button to select a different folder.
Click the Create Test Harness button.
The test and its components are created and they are checked off in the Create Test Harness dialog box as confirmation.
Click the Launch Harness button to open the new test.
The SystemTest software opens and you can see the Simulink element and the test vector that were automatically created in the Test Browser.
Note that text is added to the Test Description on the General tab indicating that this test was auto-generated from your model.
Other test properties are set to their defaults – Select Output Folder is set to Same folder as TEST-file, the results file is named "<model name>_harness_results.mat", the Generate report option is selected, and the Output Folder Numbering option is set to Always use the same folder (overwrite files). You can see these options on the Output Files tab of the Properties pane.
Select the Simulink element in the Test Browser. By default it is named "Simulate <model name>".
If you want to change the name of the element, double-click it in the Test Browser and type a new name.
The generated test automatically maps Inport blocks from the model to signals in the test vector that is created, and uses the Individual Inports blocks are mapped option. Notice in the example model shown in the beginning of this section that there are two Inport blocks, In1 and In2. Those two Inports are mapped in the Simulink element, as shown here.
TestCases (In1) is the signal called In1 in the Test Case Data test vector called TestCases. In1 is a regular signal and In2 is a bus signal. You can see that it is a bus if you expand the signal in the SystemTest Data list.
The Simulink element is configured to map the signal time to the test vector signal's time and to use the model stop time.
Select the test vector in the Test Browser. The test vector is called TestCases by default. If you want to change the name, type a new name in the Name field on the General tab.
Click the Open Test Case Editor button on the Test Vectors pane to see the test case and signals that were created from the model. By default, the test case is called TestCase1 and the signals are named the same as the Inport blocks in the model, as shown here. You can rename the test case by double-clicking it in the Test Cases list.
The example model has two Inport blocks, which appear in the signal list in the Test Case Editor. In1 is selected here and you can see that the signal was created using the same Data Type for that signal as the Inport block had in the model, double in this case.
You can see in the signal list that the Inport block In2 is a bus and its two signals are shown in the signal tree.
Signals that are created are of Type Constant, have a default Value of 0, and a default Duration of 10 seconds. You can change any of these parameters by editing them in the Signal Properties or Segment Properties.
When you are done working in the Test Case Editor, click the OK button. Any additions or changes you made will be saved to the test vector.
Once you have created the test from your model as described here, you can make additions or modifications to any part of it. You can add test cases or signals in the Test Case Editor. You can add other elements to the test, such as the General Plot element to plot your data.
Run the test.