sltest.import.sldvData
Create test cases from Simulink Design Verifier results
Syntax
Description
[
creates a test harness and test file using Simulink®
Design Verifier™ analysis results contained in owner
,testHarness
,testFile
,testCase
]
= sltest.import.sldvData(dataFile
)dataFile
. The function
returns the model component owner associated with the test case, the test harness, the test
file, and test case. If a test case or iteration is for a Requirements Table
block, the corresponding requirements are linked automatically in the test case or
iteration.
[
creates a test harness and test file using additional options specified by one or more
owner
,testHarness
,testFile
,testCase
]
= sltest.import.sldvData(dataFile
,Name,Value
)Name,Value
pair arguments. Specify name-value pair arguments after
the data file input argument.
Examples
Open the sldvdemo_cruise_control
model. Set the option to generate the test. Then, use sldvrun
to generate the Simulink Design Verifier data file. Import the Simulink Design Verifier data so it is usable by Simulink Test.
open_system('sldvdemo_cruise_control'); opts = sldvoptions; opts.Mode = 'TestGeneration'; [status,files] = sldvrun('sldvdemo_cruise_control',opts)
01-Feb-2025 14:39:48 Checking compatibility for test generation: model 'sldvdemo_cruise_control' Compiling model...done Building model representation...done 01-Feb-2025 14:39:54 'sldvdemo_cruise_control' is compatible for test generation with Simulink Design Verifier. Generating tests using model representation from 01-Feb-2025 14:39:54... Generating output files: 01-Feb-2025 14:40:13 Results generation completed. Data file: /tmp/Bdoc25a_2864802_2064130/tpd86636fd/simulinktest-ex90358021/sldv_output/sldvdemo_cruise_control/sldvdemo_cruise_control_sldvdata.mat
status = 1
files = struct with fields:
DataFile: '/tmp/Bdoc25a_2864802_2064130/tpd86636fd/simulinktest-ex90358021/sldv_output/sldvdemo_cruise_control/sldvdemo_cruise_control_sldvdata.mat'
HarnessModel: ''
SystemTestFile: ''
Report: ''
PDFReport: ''
LogFile: ''
ExtractedModel: ''
BlockReplacementModel: ''
ModelReferenceBlockReplacementModels: ''
SLTestFile: ''
[owner,testharness,testfile,testcase] = sltest.import.sldvData... (files.DataFile,'TestHarnessName','CoverageHarness',... 'TestFileName','CoverageTests')
owner = 'sldvdemo_cruise_control'
testharness = 'CoverageHarness'
testfile = '/tmp/Bdoc25a_2864802_2064130/tpd86636fd/simulinktest-ex90358021/CoverageTests.mldatx'
testcase = TestCase with properties: Name: 'New Test Case 1' TestFile: [1×1 sltest.testmanager.TestFile] TestPath: 'CoverageTests > New Test Suite 1 > New Test Case 1' TestType: 'baseline' RunOnTarget: {[0]} RunOnPlatform: {[Desktop]} Parent: [1×1 sltest.testmanager.TestSuite] Requirements: [0×1 struct] Description: '' Enabled: 1 Tags: [0×0 string]
open(testfile)
% Clean up Test Manager
sltest.testmanager.clear
sltest.testmanager.clearResults
sltest.testmanager.close
Input Arguments
Path and filename of the MAT data file generated by Simulink
Design Verifier
sldvrun
analysis, specified as a character vector or string scalar.
The data file can contain one or more baseline test cases and optionally, expected
outputs. When there are multiple test cases in the file, each test case is imported as
an iteration. When you import the file into Simulink
Test™, the import function creates an MLDATX test file, and if you specify the
ExcelFilePath
, an Excel® file containing input values at that location. If the Excel file already
exists, a new sheet is added to the file.
Example: 'ShiftLogic0/ShiftLogic0_sldvdata.mat'
Name-Value Arguments
Specify optional pairs of arguments as
Name1=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.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'TestHarnessName','DatafileHarness','CreateHarness',false
Option to add or reuse a test harness for the model or model component, which
corresponds to the test cases in the test file, specified as a comma-separated pair
consisting of 'CreateHarness'
and true
or
false
.
If you specify true
, the import function Simulink
Design Verifier creates a new test harness with the name you specify using the
'TestHarnessName'
name-value pair.
If you specify false
, the import function reuses the existing
test harness you specify using the 'TestHarnessName'
name-value
pair.
Note
If the model under analysis is a test harness, the
CreateHarness
default value is false
.
Example: 'CreateHarness',false
The test harness used for running the test cases, specified as the comma-separated
pair consisting of 'TestHarnessName'
and the name of a test
harness.
A new test harness with the specified TestHarnessName
is
created if CreateHarness
is true
. An existing
test harness with the specified TestHarnessName
is reused if
CreateHarness
is false
.
Example: 'TestHarnessName','ModelCoverageTestHarness'
The source of the test harness if CreateHarness
is
true
, specified as the comma-separated pair consisting of
'TestHarnessSource'
and 'Inport'
or
'Signal Editor'
.
Inport
— The inputs are contained in the Simulink Design Verifier data file and mapped to Inport blocks in the test harness. Using theInport
option allows you to map other inputs to the test harness Inport blocks, which can be useful for running multiple test cases or iterations using the same test harness. Both MAT and Excel files are supported when the source isInport
.Signal Editor
— The inputs are in scenarios in a Signal Editor block inside the test harness. The Signal Editor block supports MAT files that contain these inputs. You can edit the scenarios in the Signal Editor.
Example: 'TestHarnessSource','Inport'
The name for the test file created for the test cases, specified as the
comma-separated pair consisting of 'TestFileName'
and the name of a
test file, the name of the text file followed by the MLDATX extension, or the full
path to the test file.
Example: 'TestFileName','ModelCoverageTests'
Example: 'TestFileName','ModelCoverageTests.mldatx'
Example: 'TestFileName','C:\myTests\coverage\ModelCoverageTests.mldatx'
The path to the model extracted from Simulink
Design Verifier analysis, specified as the comma-separated pair consisting of
'ExtractedModelPath'
and a path.
Simulink
Test uses the extracted model to generate the test harness. By default,
sltest.import.sldvData
looks for the extracted model in the
output folder specified in the Simulink
Design Verifier configuration parameters. Use ExtractedModelPath
if
the extracted model is in a different location.
Simulink Design Verifier does not use an extracted model when you analyze a top-level model.
Example: 'Tests/ExtractedModels/'
The existing test case to use for the import operation, specified as the
comma-separated pair consisting of 'TestCase'
and an sltest.testmanager.TestCase
object. Do not specify
any other name-value pair when you use this option.
Example: 'TestCase',myTestCase
Path of the Excel file that contains input values to test, specified as a character vector or string scalar. If you specify this path, the input signals for each iteration are saved to an Excel file. If the file already exists, a new sheet is added to it.
If all test cases have
sldvData.TestCases.dataNoEffect
set to true
for all inputs, the test cases are ignored and
importing does not generate an Excel file or add a new sheet . For information about
sldvData.TestCases.dataNoEffect
, see Manage Simulink Design Verifier Data Files
(Simulink Design Verifier).
Example: 'ExcelFilePath','ShiftLogic_sldvdata.xlsx'
Output Arguments
Path of the component under test, returned as a character vector
Example: 'ShiftLogic0/ShiftLogic0_sldvdata'
Name of the test harness for running the test cases, returned as a character vector.
Name of the test file created or updated using the test cases, returned as a character vector.
Name of the newly created or updated test case, returned as an sltest.testmanager.TestCase
object. For multiple test cases, each test case
is captured as an iteration.
If a test case has sldvData.TestCases.dataNoEffect
set to
true
for all inputs, that test
case is ignored when you use sltest.import.sldvData
. For
information about sldvData.TestCases.dataNoEffect
, see Manage
Simulink Design Verifier Data Files
(Simulink Design Verifier).
Version History
Introduced in R2015b
See Also
createInputDataFile
| sldvrun
(Simulink Design Verifier)
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)