Author a Baseline Test Case
In this example, you use the Simulink Test Manager to create a test file and author a test case. You specify the test properties by selecting the system under test and coverage collection settings. Then, you simulate the model to capture the baseline data and run the test case to validate the data and confirm that the signals are the same.
You can also create a test case programmatically or use the Test for Model Component wizard. For information see Create and Run Test Cases with Scripts and Generate Tests and Test Harnesses for a Model or Components.
Open the Model and Test Manager
1. Open the sldemo_absbrake
model.
open_system("sldemo_absbrake");
2. In the Apps tab, in the Model Verification, Validation, and Test section, click Simulink Test.
3. In the Tests tab, in the Test Cases section, click Simulink Test Manager.
Create the Test File and Specify Test Properties
1. In the Test Manager, click New > Test File.
2. Name the file baselineTestFile
and save the file.
3. By default, the Test Manager creates a test suite with one baseline test case, New Test Case 1
. In the Test Browser, right-click New Test Case 1
and select Rename. Rename the test case to baselineTestCase
.
4. Load the sldemo_absbrake
model into the test case. In the System Under Test section, click the Use current model button .
5. To collect coverage in the test case, you must enable coverage collection in the test file. In the Test Browser, select baselineTestFile
. Expand the Coverage Settings section. Select Record coverage for system under test. The Coverage Settings section of the test case updates to match the coverage settings selected in the test file. For more information on coverage, see Collect Coverage in Tests.
Capture and Validate Baseline Data
1. In the Test Browser, select baselineTestCase
. In the Baseline Criteria section, click Capture and specify a location in the File field. Name the file absbrake_baselinedata
and click Capture. The test case simulates the model and captures the signals that are selected for signal logging. The Baseline Criteria section displays the logged signals with default tolerances of 0
. For more information about how to mark signals for logging in your model, see Save Signal Data Using Signal Logging. Alternatively, you can select signals in the Simulation Outputs section of the Test Manager. See Simulation Outputs.
2. In the Test Manager, click Run. In the Results and Artifacts pane, expand the Baseline Criteria Result section and select a signal. The upper plot displays the simulation output data and baseline data and the lower plot displays the tolerance and difference between the simulation output data and baseline data. Review the signals to confirm that there is a zero difference between the simulation output and baseline data, as expected.