Main Content

Extend Test Cases for Modified Model

Suppose that you have a model that you have already analyzed using Simulink® Design Verifier™, and you modify the model. The original test suite may not record 100% coverage for the modified model. Reanalyze the modified model to make sure that it satisfies all the new test objectives. Instead of reanalyzing the entire model, you focus the new analysis on just the modified part of the model. In this way, you leverage the test cases created for the original model, extending them to satisfy any new objectives.

This example uses the sldvdemo_cruise_control model. You analyze the model and generate test cases. Then you analyze a modified version of that model, sldvdemo_cruise_control_mod, extending the test cases from the original analysis. The analysis returns a complete test suite for the new model.

Create Starting Test Cases

Analyze the sldvdemo_cruise_control model and generate test cases that achieve 100% coverage.

1. Open the example model:

open_system('sldvdemo_cruise_control')

2. To start a Simulink® Design Verifier™ analysis for the sldvdemo_cruise_control model, click Generate Tests.

The analysis satisfies 34 test objectives for the sldvdemo_cruise_control model. The software stores the resulting data file in a subfolder of the MATLAB® Current Folder sldv_output\sldvdemo_cruise_control\sldvdemo_cruise_control_sldvdata.mat

In the next section, when you analyze the modified model, this data file specifies the starting test cases that you extend.

3. Close the sldvdemo_cruise_control model and all the files created by the analysis. If asked, do not save any changes you made to the model.

Extend Existing Test Cases

The sldvdemo_cruise_control_mod model is a modified version of sldvdemo_cruise_control. The Controller subsystem contains a Saturation block that specifies that the target speed cannot exceed 70.

Open the modified model and analyze it, extending the test cases that you generated when analyzing the sldvdemo_cruise_control model:

1. Open the example model, the modified version of sldvdemo_cruise_control:

open_system('sldvdemo_cruise_control_mod')

2. Double-click the Controller subsystem to see the change to the original model, a Saturation block that specifies the maximum speed:

saturation_block_target_speed.png

3. Close the Controller subsystem.

4. On the Design Verifier tab, click Test Generation Settings.

5. In the Configuration Parameters dialog box, on the Test Generation pane, under Existing test cases, select Extend existing test cases.

6. In the Data file field, click Browse and navigate to the MAT-file created in the MATLAB® Current Folder when analyzing the original model, sldv_output\sldvdemo_cruise_control\sldvdemo_cruise_control_sldvdata.mat

7. Clear Separate objectives satisfied with the existing tests/coverage data in the report.

When you clear this option, the analysis includes the test cases recorded in the file sldvdemo_cruise_control_sldvdata.mat in the final test suite.

8. Click Apply to save these settings.

9. To start the analysis, click Generate Tests.

The analysis first loads the 34 objectives satisfied by the initial test cases. Then it adds extra time steps to those test cases and tries to satisfy any missing objectives.

10. In the Results Summary window, click Generate detailed analysis report.

The analysis satisfied a total of 38 satisfied objectives for the sldvdemo_cruise_control_mod model. The analysis satisfied four additional objectives that correspond to the Saturation block.

saturation_block_objectives.png

See Also