This example shows how to generate test cases for two custom Test Objective blocks using Observer Reference block and use model representation to reanalyze the design model. For more information, see Isolate Verification Logic with Observers. To reanalyze the model, you update the verification logic and set the Rebuild model representation option to
If change is detected. For more information, see Model Representation for Analysis.
In the Test Objective block, the block "True" forces the output signal to be 2. The block "Edge" inside "Masked Objective" specifies that the output signal transitions from 2 to 1. To open the model, enter:
To replace the Verification Subsystem Masked Objective in the model by the Observer Reference block, follow these steps:
(a) Right-click on the Masked Objective in the
sldvdemo_debounce_testobjblks model. In the context menu, click Observers > Move selected block to Observer > New Observer.
(b) Click Yes on move 'Verify Output' to Observer dialog box that appears after step (a).
(c) An Observer Reference block is added to your system model, and an Observer model
sldvdemo_debounce_testobjblks_Observer1 is created and opened.
(d) Save the file
sldvdemo_debounce_validprop_Observer1 in a writable folder on the MATLAB path.
(e) Double-click on the Observer port to open the Manage Observer configuration window. The signal
Switch 1 is automatically mapped to the Observer Port block in the
(f) Select the input signal to the Masked Objective subsystem in the
sldvdemo_debounce_testobjblks and click on Test Point in the Signal pane to make sure that Simulink Design Verifier successfully build the model representation for analysis.
To perform the test generation analysis, follow these steps:
On the Design Verifier tab, click Generate Test.
After the analysis completes, the Results Summary window displays that both objectives are satisfied with the test case.
To view the detailed analysis report, in the Results Summary window, click HTML. In the report, the Test Objectives Status chapter lists the status of the objectives for Design Model and Observers Model(s) in separate subsections.
To generate the test case for the functional requirement, the
debounced signal transitions from 1 to 2 without rebuilding the model representation for design model. To enable the reuse of design model representation, follow these steps:
(a) On the Design Verifier tab, click Test Generation Settings > Settings.
(b) In the Configurations Parameters dialog box, on the Design Verifier pane, in Advanced parameters, set the Rebuild model representation option to
If change is detected and Click OK.
(c) To update the model parameters, follow these steps:
1. In the
sldvdemo_debounce_testobjblks_Observer1 window, double-click to open the Masked Objective subsystem and change the value of constant
In1 from 1 to 2 and relational operator from
2. Save the changes in a writable MATLAB path.
(d) Perform Test Case Generation Analysis and Review Results. On the Design Verifier tab, click Generate Tests. The software validates the cached design model representation, detects no change in design model and reuses the representation for analysis.
After the analysis completes, the Results Summary window display that only one test objective is satisfied.
To view the detailed analysis report, in the Results Summary window, click HTML.
Note: If you create a new model, by default, the Rebuild model representation option is set to
If change is detected. The software validates the cache model representation, detects no change, and reuses the model representation for analysis.