Model verification often requires repeated testing to achieve certain objectives or coverage criteria. If you run repeated tests, consider using the Test Manager in Simulink® Test™ to structure your test cases, archive test results, and generate reports. You can generate test cases using Simulink Design Verifier™ and export the test inputs to new test cases automatically created in the Simulink Test Manager.
To export generate inputs to new test cases in Simulink Test:
Choose an existing Simulink Design Verifier results file or generate new results by analyzing your model.
If you use an existing results file, you can load results by either:
Using the Simulink
sltest.import.sldvData (Simulink Test).
Using Load Earlier Results in the Design Verifier tab. Select the MAT-file or Excel® file with the analysis results.
If you run a model analysis, the Design Verifier Results Summary window appears after the analysis completes.
In the results summary window, click Export test cases to Simulink Test. The Export Design Verifier Test Cases dialog box opens.
In the Export Design Verifier Test Cases dialog box, you can:
Harness Source to
Signal Editor or
Set the Test Data Format to MAT or Excel.
Click OK to generate the test file and test harness.
Simulink Test generates the test file and test harness. In the Test Manager, expand the new test file in the Test Browser to see the individual test cases.
This example shows how to generate test cases to achieve coverage objectives for a controller subsystem. The example also shows how to add functional test cases from test harnesses in the model. This example requires a Simulink Test license.
The model is a closed-loop heat pump system. The controller accepts the measured room temperature and set temperature inputs. The controller outputs a bus of three signals controlling the fan, heat pump, and the direction of the heat pump. The model contains a harness that tests heating and cooling scenarios.
Open the model.
Set the current working folder to a writable folder.
In the model, generate tests for the Controller subsystem. Right-click the Controller block and select Design Verifier > Generate Tests for Subsystem.
In the Simulink Design Verifier Results Summary window, click Export test cases to Simulink Test.
In the Export Design Verifier Test Cases dialog box, click OK.
The Test Manager displays six new test cases in the test file.
In the model, click the perspective view badge to see the new test harness.
Add a test case to the other test harness in the model. In the Test Manager, point to the new test file name and click the Synchronize Test File button .
The Test Manager prompts you to add tests for the Requirement2 test harness.
Simulation for the test type and click
Update Test File.
The Test Manager adds the Requirement2 test case to the test file.
sltest.import.sldvData (Simulink Test)