Generate Tests for a Subsystem

Use the Test Manager to generate a test case for a subsystem. You can create a baseline, equivalence, or simulation test case. Generating the test case:

  • Creates a test harness for the subsystem. The test harness provides a separate simulation environment from the main model.

  • Simulates the main model and captures the subsystem input data from the main model simulation.

  • For baseline tests, captures output data in a MAT-file or Microsoft® Excel® file. The output is the test case baseline data.

  • Adds the input and output files to the test case.

After you create the test case, configure the test case if you need additional options such as coverage or reports.

You add a generated test case for a subsystem to a test file. If you need a test file to add the test case to, create one.

  • Select the test file before you generate the test to add a test suite containing the test case.

  • Select a test suite before you generate the test case to add the test case to the test suite. Or, select a test case in a test suite to add the test case to the test suite.

Generate the Subsystem Test Case

You can save the input data to a MAT-file or Excel file. When creating a baseline test, selecting Excel saves the input and output data in the same file. For more information on using Excel files in Test Manager, see Format Test Case Data in Excel.

  1. In the model that contains the subsystem that you want to create the test for, select the subsystem.

  2. In Test Manager, select the test file or test suite that you want to create the test case in, and then select New > Test for Subsystem.

  3. In the dialog box, click the Use currently selected subsystem button to fill in the Subsystem and Top model fields.

  4. Select the test type—baseline, equivalence, or simulation—and specify the file format.

  5. Depending on the test type and the file format, you can specify the location for your inputs and your baseline outputs and the sheet name for Excel data.

  6. Click Create. Test Manager adds a test harness to the subsystem and simulates the model.

    After simulation completes, the test case includes inputs and, for baselines, outputs.

    • For equivalence tests, inputs are added to the test case in the Inputs section under Simulation 1.

    • For simulation tests, inputs are added under Inputs.

    • For baseline tests, inputs are added under Inputs and outputs are added under Baseline Criteria.

  7. Finish configuring the harness and test case for your test scenario.

  8. Save the model and the test case.

Related Topics