How do you create test cases in Simulink Design Verifier for a subsystem with a 1-D lookup table / switch / selector blocks?

1 view (last 30 days)
I want to use Simulink Design Verifier to automatically create test cases for a subsystem with a 1-D lookup table / switch / selector blocks while ensuring full coverage. How do I do this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Oct 2023
Edited: MathWorks Support Team on 2 Feb 2024
The workflow for generating test cases for model coverage is documented and can be accessed by running the specified command in MATLAB 2017a:
>> web(fullfile(docroot, 'sldv/ug/generate-test-cases-for-model-decision-coverage.html'))
The example used in the link above is a switch block with 1 inport and 1 outport. However, this link does not address the cases for using a switch/ a lookup table/ a selector block in your subsystem. You will need to do all the steps as mentioned in the article for and a few more. Before you check the model compatibility, you will need to add a block replacement rule corresponding to the block you want to use to generate all the test cases based on the breakpoints/inputs.
These replacement rules are documented and can be accessed by running the below command in MATLAB 2017a:
>> web(fullfile(docroot, 'sldv/ug/built-in-block-replacements.html'))
For example: to create the test cases based on the breakpoints for a 1-D lookup table you will need to go the configuration parameters of your subsystem with the lookup table and navigate to the following section: Design Verifier  > Block replacements and add 'blkrep_rule_lookup_normal' to the List of block replacement rules section as shown in the attached image: blkRep.png
If you generate test cases without adding this file, no objectives will be set and no values will be seen in your data inspector windows. Note you will need to add multiple files depending on what blocks you use in your model accordingly.
In case you have a lookup table whose output feeds into the first input to a switch, you will notice that you get less than 100% coverage than before. The main reason for this is that the Switch block uses the output of the lookup table only when the second input to the Switch is false (or a different scenario where the lookup table's output is used conditionally). When the lookup table's output is used conditionally, then not all of the interpolation intervals will be covered and you will get less than 100% coverage. For the Coverage report to show 100% table coverage on this model, you will need to disable the ‘Conditional input branch execution’ in Optimization pane of Configuration Parameters, before simulating the test-case. If you have any difficulty in finding this parameter, you can simply type in 'Conditional input branch execution' in the search box of the All parameters tab in the Configuration Parameters dialog window and then uncheck this option before running the script.
Additional links: 
Please follow the below link to search for the required information regarding the current release:

More Answers (0)

Products


Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!