coder.profile.test.generateTests - Generate decision coverage tests for execution-time analysis - MATLAB (original) (raw)
Main Content
Generate decision coverage tests for execution-time analysis
Since R2024a
Syntax
Description
[decisionCoverageTest](#mw%5F27ae17bc-3dde-4098-b560-2280247ad085) = coder.profile.test.generateTests([modelName](#mw%5F503e40ee-b734-4bdf-afae-f7757ee873df))
generates decision coverage test cases for the specified model by using Simulink® Design Verifier™. The function ensures 100% decision coverage. It saves the generated test cases in both a MAT data file and a Simulink Test™ compatible MLDATX file. It also generates an harness to run the test file in the current folder.
If you have a Simulink Test license, you can use the MLDATX file for execution-time analysis. If you do not have a Simulink Test license, you can import the tests in the MAT data file to your model as inputs and use those for analysis. For more information on importing data into a model, see Overview of Signal Loading Techniques andLoad Input Data for Basic Test Cases. To generate test cases, this function can change model parameter settings which are restored back to the original settings after test generation. In such cases, you get a warning message.
[decisionCoverageTest](#mw%5F27ae17bc-3dde-4098-b560-2280247ad085) = coder.profile.test.generateTests([modelName](#mw%5F503e40ee-b734-4bdf-afae-f7757ee873df),[Name=Value](#namevaluepairarguments))
specifies additional name-value arguments. Use this syntax with the input argument in the preceding syntax.
Examples
This example show how you can usecoder.profile.test.generateTests
to generate decision coverage tests.
Open the CriticalPathIdentify
model.
openExample('CriticalPathIdentify'); model= "CriticalPathIdentify";
Generate decision coverage tests, using this command:
decisionCoverageTest = coder.profile.test.generateTests(model)
Data file: \users\taprj\sldv_output\CriticalPathIdentify\CriticalPathIdentify_sldvdata.mat
decisionCoverageTest =
'\users\taprj\sldv_output\CriticalPathIdentify\CriticalPathIdentify_test.mldatx'
Input Arguments
Name of the model, specified as a character vector or string.
Example: "CriticalPathIdentify"
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, where Name
is the argument name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Example: decisionCoverageTest = coder.profile.test.generateTests("mymodel", MaxTime=100)
You can provide a custom sldvoptions
object. If you do not provide an object, the function creates an object that have these parameter settings, which are different from their default settings.
Parameter | Value |
---|---|
TestgenTarget | 'GenCodeTopModel' |
RandomizeNoEffectData | 'on' |
ModelCoverageObjectives | 'Decision' |
For more information, see sldvoptions (Simulink Design Verifier).
Maximum time for test generation, specified as a positive integer.
MaxTime
specifies the maximum time in seconds for test generation. If the specified time is not sufficient for test generation, the function issues an error and suggests increasing MaxTime
value.
Example: decisionCoverageTest = coder.profile.test.generateTests("mymodel", MaxTime=100)
When you set Verbose
to true
, the function displays the test generation progress details in the MATLAB Command Window and opens the Simulink Design Verifier Results Summary window.
Example: decisionCoverageTest = coder.profile.test.generateTests("mymodel", Verbose=true)
Data Types: logical
Output Arguments
Path of the MLDATX test file, returned as a character vector. The function also returns a path to the MAT data file containing the generated test cases.
Version History
Introduced in R2024a