Main Content

Enhanced MCDC Coverage in Simulink Design Verifier

Enhanced Modified Condition Decision Coverage (MCDC) is an extension of modified condition decision coverage. For a test block, enhanced MCDC generates test cases that avoid masking effects from downstream blocks, so that the test block has an effect on the output.

To detect the effect of a test block by using the enhanced MCDC coverage objective, you can consider a standard model coverage objective of a test block or you can author your own custom test objectives for analysis. For more information, see:

To generate test cases by using enhanced MCDC model coverage objectives, and then analyzing the results, see Basic Workflow for Enhanced MCDC Analysis.

Use Model Coverage Objectives for Enhanced MCDC Coverage

For a given test block, you can detect the effect on a model coverage objective from the downstream blocks. When you generate test cases by using enhanced MCDC model coverage objectives, the generated test cases avoid the masking effect from the downstream blocks. The model coverage objective is detectable at a detection site.

Consider this model that consists of a cascade of Switch, Min, and Max blocks.

The test cases generated for enhanced MCDC coverage ensure that the decision objective of the Switch (Simulink Coverage) test block is not masked by the downstream Min and Max blocks. The generated test cases ensure that these nonmasking conditions for Min and Max blocks are satisfied:

  1. F < D, ensures that the Min block does not mask the Switch output.

  2. G > E, ensures that the Max block does not mask the Min output.

The decision objective of the Switch block and the nonmasking conditions of the Min and Max blocks are satisfied along the path and are detected at the detection site (Out1). For example, the path starts from the output signal of the Switch block, propagates along the Min block, and ends at the output signal of the Max block (highlighted in the example model).

Enhanced MCDC criteria ensure better quality test cases because the test case detects the effect of a model coverage objective of the test block at the detection site. To analyze a model for enhanced MCDC analysis, see example Analyze Model for Enhanced MCDC Analysis.

Author Custom Test Objectives for Enhanced MCDC Coverage

Enhanced MCDC considers the default coverage objectives of a test block that are detectable at the detection site. To check the detectability status of a custom test objective, you can author the test objective of a model object, and then perform enhanced MCDC analysis.

Consider this model that consists of a Product block and a Min block. The Product block does not have a coverage objective.

You can author a custom test objective for the Product block to render the output value less than 0 and detect the effect of the custom test objective at a detection site.

Steps for Authoring Custom Test Objectives

This workflow describes the steps for authoring custom test objectives for a block.

Step 1: Create a library of atomic masked subsystem to author the custom test objectives. The masked subsystem consists of these blocks:

  • Block under consideration, for example, a Product block.

  • Logic to encode the custom test objective, for example, a MATLAB Function block.

  • Simulink® Design Verifier™ Test Objective blocks.

Step 2: In the masked subsystem:

  • Add isEnabledForDetectability parameter and set the parameter to On.

  • Add the detectBlock parameter with the name of the block under consideration.

  • Set the Evaluate attribute of the detectBlock parameter to Off.

Step 3: Define the block replacement rule to replace the block under consideration with a masked subsystem.

To author custom test objectives, use blkrep_rule_product_customTestObjective.m block replacement rule example file. In the block replacement file, you update the rule.BlockType and rule.ReplacementPath based on your model blocks. For more information, see Block Replacements for Unsupported Blocks.

Step 4: Configure your model with the block replacement rule. In the Configuration Parameters dialog box, in Design Verifier > Block Replacements pane, enter the List of block replacement rules.

Step 5: Select Enhanced MCDC for Model coverage objectives and perform test generation analysis.

Analyze Custom Test Objectives in Model for Enhanced MCDC

This example shows how to author custom test objectives for the Product block in sldvCustomTestObjectiveExample model. Also, it shows how you can detect the effect of the test objective at a detection site.

1. Open the sldvCustomTestObjectiveExample model:

open_system('sldvCustomTestObjectiveExample');

product_model_custom.png

Library of atomic masked subsystem: The blkReplacementlib_customTestObjective library consists of the custProduct masked subsystem. The logic to encode the custom test objective is defined in the MATLAB Function block. The getCustomTestObjectives MATLAB Function block consists of two custom conditions for the Test Objective blocks.

product_target_custom_library.png

The custProduct masked subsystem is preconfigured with these parameters. For more information, see Mask Editor Overview.

masked_system_parameters.png

Block replacement rule to replace the block under consideration with a masked subsystem: The sldvCustomTestObjectiveExample model is preconfigured with the block replacement options. The block replacement rule is defined in the blkrep_rule_product_customTestObjective file that replaces the Product block with the custProduct masked subsystem.

block_replacement_pane.png

2. To configure the model for enhanced MCDC objectives, on the Design Verifier tab, click Test Generation Settings. In the Configuration Parameters dialog box, in Design Verifier > Test Generation pane, for Model coverage objectives, select Enhanced MCDC. Click OK.

3. To generate test cases, click Generate Tests.

The software analyzes the replacement model for test generation.

custom_test_authoring_results.png

4. The results are highlghted in the model after the analysis completes. To analyze the detectability of the Product block, click the Product block.

custom_test_authoring_product_results.png

The results show that the test objectives of the Product block are detectable. The test case is generated.

Note: The software is unable to confirm the objectives status through validation results for the objectives introduced by block replacement. Therefore, the test objective status is reported as satisfied - needs simulation. For more information on validation, see How Simulink Design Verifier Reports Approximations Through Validation Results.

5. Click View test case. The harness model and the Signal Editor block opens. Click on Open Signal Editor button to view the test case.

6. To view the detailed analysis report, click HTML in the Results Summary. The Block Replacement Summary provides details about the replaced blocks.

block_replacement_report.png

The Test Objectives Status section lists the objectives. The test objective that is detectable at the detection site is summarized in the table.

custom_test_authoring_report.png

Related Topics