Main Content

Generate Test Cases for a Subsystem

You can analyze a subsystem within a model. This technique is good for large models, where you want to review the analysis in smaller, manageable reports.

This example shows how to analyze the Controller subsystem in the sldvdemo_cruise_control model.

  1. Open the example model:

    sldvdemo_cruise_control
  2. Right-click the Controller subsystem, and select Design Verifier > Enable ‘Treat as Atomic Unit’ to Analyze.

    The Function Block Parameters dialog box for the Controller subsystem opens.

  3. Select Treat as atomic unit.

    An atomic subsystem executes as a unit relative to the parent model. Subsystem block execution does not interleave with parent block execution. You can extract atomic subsystems for use as standalone models.

    To analyze a subsystem with Simulink® Design Verifier™, set the Treat as atomic unit parameter.

    After you set the parameter, other parameters become available, but you can ignore them.

  4. To close the dialog box, click OK.

  5. On the Simulation tab, in the File section, select Save > Save As and save the Cruise Control Test Generation model with a new name.

  6. To start the subsystem analysis and generate test cases, right-click the Controller subsystem, and select Design Verifier > Generate Tests for Subsystem.

  7. The Simulink Design Verifier software analyzes the subsystem. When the analysis is complete, view the analysis results for the Controller subsystem by clicking one of the following options:

    • Highlight analysis results on model

    • View tests in Simulation Data Inspector

    • Detailed analysis report

    • Create harness model

    • Export test cases to Simulink Test

    • Simulate tests and produce a model coverage report

    Note

    After processing a certain number of objectives, if the analysis stops, or if the analysis times out, you can use the Test Generation Advisor to better understand which subsystems are causing the problem. For more information, see Use Test Generation Advisor to Identify Analyzable Components.

  8. Review the results of the subsystem analysis and compare the results to the results of the full-model analysis as described in Analyze a Model:

    • The subsystem analysis analyzes the Controller as a standalone model.

    • The Controller subsystem contains all the test objectives in the Cruise Control Test Generation model. Both the analyses generate the same test cases.