Main Content

sldvmakeharness

Generate harness model

Description

[savedHarnessFilePath] = sldvmakeharness(model) generates a test harness from the model, which is a handle to a Simulink® model or the model name. sldvmakeharness returns the path and file name of the generated harness model in savedHarnessFilePath. sldvmakeharness creates an empty harness model. The test harness includes one default test case that specifies the default values for all input signals.

[savedHarnessFilePath] = sldvmakeharness(model, dataFile) generates a test harness from the data file dataFile.

[savedHarnessFilePath] = sldvmakeharness(model, dataFile, harnessOpts) generates a test harness from model by using the dataFile and the harnessOpts, which specifies the harness creation options. If the dataFile is not available, requires '' for dataFile.

If the software generates a harness, it does not imply that your model is compatible with the Simulink Design Verifier™ software.

example

Examples

collapse all

Create a test harness for the sldvdemo_cruise_control model by using the default options.

Open the sldvdemo_cruise_control model by using the default options and create a harness model:

openExample('sldv/CruiseControlTestGenerationExample',...
'supportingFile', 'sldvdemo_cruise_control');
harnessopts=sldvharnessopts();
[harnessfile] = sldvmakeharness('sldvdemo_cruise_control', '', harnessopts);

Input Arguments

collapse all

Handle to a Simulink model or the model name.

Name of the sldvData file, structure, or a spreadsheet.

A structure whose fields specify these configurations for sldvmakeharness, as listed in this table.

FieldDescription
harnessFilePath

Specifies the file path for creating the harness model. If an invalid path is specified, sldvmakeharness does not save the harness model, but it creates and opens the harness model. If you do not specify this option, sldvmakeharness generates a new harness model and saves it in the MATLAB® current folder.

Default: ''

modelRefHarness

Generates the test harness model that includes the model in a Model block. When false, the test harness model includes a copy of the model.

Default: true

usedSignalsOnly

When the harnessSource parameter is set to Signal Editor, the Signal Editor block in the harness model consists of unused bus signals in addition to the input signals in the model.

When true, the Signal Builder block in the harness model has signals only for input signals in the model. Model must be compatible with the Simulink Design Verifier software to detect those input signals.

Default: false

harnessSource

When set to Signal Editor, Simulink Design Verifier generates a harness model with the Signal Editor block as the Inputs block.

Default: Signal Editor

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: 'Description','My new description.'

Specifies the file path for creating the harness model. If an invalid path is specified, sldvmakeharness does not save the harness model, but it creates and opens the harness model. If this option is not specified, sldvmakeharness generates a new harness model and saves it in the MATLAB current folder.

Default: ''

Generates the test harness model that includes model in a Model block. When false, the test harness model includes a copy of model.

Default: true

When true, the Signal Editor block in the harness model has signals for only input signals used in the model. model must be compatible with the software to detect the used input signals.

When the harnessSource parameter is set to Signal Builder, the Signal Builder block in the harness model consists of unused bus signals in addition to the input signals in the model.

Default: false

When set to Signal Editor, Simulink Design Verifier generates a harness model with the Signal Editor block as the Inputs block.

When set to Signal Builder, Simulink Design Verifier generates a harness model with the Signal Builder block as the Inputs block.

Default: Signal Editor

Output Arguments

collapse all

The path and file name of the generated harness model.

Tips

To create a default harnessOpts object, use sldvharnessopts.

Alternatives

sldvmakeharness creates a test harness model without analyzing the model. To analyze the model and create a test harness:

  1. Open the model.

  2. On the Design Verifier tab, in the Prepare section, from the drop-down menu for the mode settings, click Settings.

  3. In the Configuration Parameters dialog box, on Design Verifier > Results pane, in Harness model options, set the options that you want.

  4. Click OK.

  5. To perform test generation analysis, on Design Verifier tab, in the Mode section, select Test Generation.

  6. Click Generate Tests.

Version History

Introduced in R2009b

expand all