Main Content

sltest.import.sldvData

Create test cases from Simulink Design Verifier results

Description

[owner,testHarness,testFile,testCase] = sltest.import.sldvData(dataFile) creates a test harness and test file using Simulink® Design Verifier™ analysis results contained in dataFile. The function returns the model component owner associated with the test case, the testHarness, and the testFile.

[owner,testHarness,testFile,testCase] = sltest.import.sldvData(dataFile,Name,Value) creates a test harness and test file with additional options specified by one or more Name,Value pair arguments. Specify name-value pair arguments after the data file input argument.

Examples

collapse all

Create a test file and test harness for the ShiftLogic subsystem in the sldvdemo_autotrans model. The inputs reflect the analysis objectives.

Analyze the ShiftLogic subsystem with Simulink Design Verifier to generate test inputs for subsystem coverage. The results data file is ShiftLogic_sldvdata.mat.

Create the test case.

[component,harness,testfile] = ...
   sltest.import.sldvData...
   ('./sldv_output/ShiftLogic/ShiftLogic_sldvdata.mat',...
   'TestHarnessName','CoverageHarness',...
   'TestFileName','CoverageTests')

Open the test harness.

sltest.harness.open(component,harness)

Open the test file.

open(testfile)

Create a test file and test harness for the ShiftLogic subsystem in the sldvdemo_autotrans model, using an existing test harness.

Analyze the ShiftLogic subsystem with Simulink Design Verifier to generate test inputs for subsystem coverage. The results data file is ShiftLogic_sldvdata.mat. The existing test harness is named DatafileHarness.

Create the test case.

[component,harness,testfile] = sltest.import.sldvData...
('./sldv_output/ShiftLogic/ShiftLogic_sldvdata.mat',...
'TestHarnessName','DatafileHarness','TestFileName','CoverageTests',...
'CreateHarness',false)

Open the test harness.

sltest.harness.open(component,harness)

Open the test file.

open(testfile)

Input Arguments

collapse all

Path and file name of the data file generated by Simulink Design Verifier analysis, specified as a character vector or string scalar. The input file is a MAT file. When the file is imported into Simulink Test™, sldvData creates an MLDATX file, and an Excel® file at the location specified in ExcelFilePath. If the Excel file already exists, a new sheet is added to the file.

Example: 'ShiftLogic0/ShiftLogic0_sldvdata.mat'

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'TestHarnessName','DatafileHarness','CreateHarness',false

Option to add a test harness to 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, use a new test harness name with the 'TestHarnessName' name-value pair.

If you specify false, use an existing test harness name with 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.

Use a new test harness name if 'CreateHarness' is true and an existing test harness name if 'CreateHarness' is false.

Example: 'TestHarnessName','ModelCoverageTestHarness'

The source of the new test harness, specified as the comma-separated pair consisting of 'TestHarnessSource' and 'Inport' or 'Signal Editor'.

Use a new test harness name if 'CreateHarness' is true and an existing test harness name if 'CreateHarness' is false.

Example: 'TestHarnessName','ModelCoverageTestHarness'

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.

Example: 'TestFileName','ModelCoverageTests'

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 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. When you generate test cases for a top-level model, Simulink Test does not use 'ExtractedModelPath'.

Example: 'Tests/ExtractedModels/'

The test case to reuse for import operation, specified as the comma-separated pair consisting of 'TestCase' and the name of the test case. Do not specify any other name-value pair when you use this option.

Example: 'TestCase','ModelCoverageTest2'

Path of the Excel file, specified as a character vector or string scalar.

Example: 'TestCase','ModelCoverageTest2'

Output Arguments

collapse all

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 a character vector.

Introduced in R2015b