Main Content

Export Test Cases to Simulink Test

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:

  1. 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 Test command 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.

  2. In the results summary window, click Export test cases to Simulink Test. The Export Design Verifier Test Cases dialog box opens.

  3. In the Export Design Verifier Test Cases dialog box, you can:

    • Choose Harness Source to Inport, Signal Editor or Signal Builder.

    • Set the Test Data Format to MAT or Excel.

    • Click OK to generate the test file and test harness.

  4. 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.

Generate and Export Test Cases to Simulink Test

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.

  1. Open the model.

  2. Set the current working folder to a writable folder.

  3. In the model, generate tests for the Controller subsystem. Right-click the Controller block and select Design Verifier > Generate Tests for Subsystem.

  4. In the Simulink Design Verifier Results Summary window, click Export test cases to Simulink Test.

  5. In the Export Design Verifier Test Cases dialog box, click OK.

    The Test Manager displays six new test cases in the test file.

  6. In the model, click the perspective view badge to see the new test harness.

  7. 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 .

  8. The Test Manager prompts you to add tests for the Requirement2 test harness. Select Simulation for the test type and click Update Test File.

    The Test Manager adds the Requirement2 test case to the test file.

See Also

(Simulink Test)