Documentation

sltest.harness.create

Create test harness

Syntax

sltest.harness.create(harnessOwner)
sltest.harness.create(harnessOwner,Name,Value)

Description

sltest.harness.create(harnessOwner) creates a test harness for the model component harnessOwner, using default properties.

sltest.harness.create(harnessOwner,Name,Value) uses additional options specified by one or more Name,Value pair arguments.

Examples

collapse all

Create harness for the f14 model. The harness is called sample_harness and has a Signal Builder block source and a scope sink.

f14;
sltest.harness.create('f14','Name','sample_harness','Source',...
'Signal Builder','Sink','Scope')

Create harness for the Controller subsystem of the f14 model. The harness allows editing of Controller and uses default properties for the other options.

f14;
sltest.harness.create('f14/Controller','EnableComponentEditing',true);

Create a default harness for the Controller subsystem of the f14 model.

f14;
sltest.harness.create('f14/Controller');

Input Arguments

collapse all

Model or component handle or path, specified as a character vector or double.

Example: 1.9500e+03

Example: 'model_name'

Example: 'model_name/Subsystem'

Name-Value Pair 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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Name','controller_harness','Source','Signal Builder','Sink','To File' specifies a harness named controller_harness, with a signal builder block source and To File block sinks for the component under test.

collapse all

The name for the harness you create, specified as the comma-separated pair consisting of 'Name' and a valid MATLAB filename.

Example:

'Name','harness_name'

The harness description, specified as the comma-separated pair consisting of 'Description' and a character vector.

Example:

'Description','A test harness'

The input to the component, specified as the comma-separated pair consisting of 'Source' and one of the possible source values.

Example:

'Source','Signal Builder'

For a custom source, the path to the library block to use as the source, specified as the comma-separated pair consisting of 'CustomSourcePath' and the path.

Example:

'CustomSourcePath','simulink/Sources/Sine Wave'

The output of the component, specified as the comma-separated pair consisting of 'Sink' and one of the possible sink values.

Example:

'Sink','Scope'

For a custom sink, the path to the library block to use as the sink, specified as the comma-separated pair consisting of 'CustomSinkPath' and the path.

Example:

'CustomSinkPath','simulink/Sinks/Terminator'

Option to add a separate Test Assessment block to the test harness, specified as a comma-separated pair consisting of 'SeparateAssessment' and false or true. 'Source' must be 'Test Sequence'.

Example:

'SeparateAssessment',true

For a component or block diagram that has function call trigger inputs, this is an option specifying how to connect function call trigger inputs, specified as a comma-separated pair consisting of 'DriveFcnCallWithTestSequence' and true or false.

true connects function call trigger inputs to outputs of a Test Sequence block. Choose true if you want to schedule multiple input function calls in a determined order.

false connects function call trigger inputs to Inport blocks. Choose false if you want to map an external Boolean timeseries signal to the inports, to drive the function call triggers.

Example:

'DriveFcnCallWithTestSequence',false

An option to specify when the component under test synchronizes between the main model and the test harness.

  • 'SyncOnOpenAndClose' rebuilds the component under test from the main model when the test harness opens, and pushes changes from the component under test to the main model when the test harness closes.

  • 'SyncOnOpen' rebuilds the component under test from the main model when the test harness opens. It does not push changes from the component under test to the main model when the test harness closes.

  • 'SyncOnPushRebuildOnly' rebuilds and pushes changes only when you manually initiate rebuild or push for the entire test harness. For more information, see Synchronize Changes Between Test Harness and Model.

Example:

'SynchronizationMode','SyncOnOpen'

Option to specify harness creation without compiling the main model, specified as a comma-separated pair consisting of 'CreateWithoutCompile' and false or true.

false compiles the model and runs other operations to support the harness build.

true creates the harness without model compilation.

Example:

'CreateWithoutCompile',false

An option to specify what type of block to use in the test harness, specified as a comma-separated pair consisting of 'VerificationMode' and the type of block to use. SIL and PIL blocks require Simulink Coder.

Example:

'VerificationMode','SIL'

Option to have the harness rebuild when it opens, specified as the comma-separated pair consisting of 'UseDefaultName' and false or true.

Example:

'RebuildOnOpen',true

Option to have the configuration set and model workspace entries updated during test harness rebuild, specified as the comma-separated pair consisting of 'RebuildModelData' and true or false.

Example:

'RebuildModelData',true

Option to have each test harness saved as a separate SLX file, specified as the comma-separated pair consisting of 'SaveExternally' and true or false. A model cannot use both external and internal test harness storage. If a model already has test harnesses, a new test harness follows the storage type of the existing harnesses, which this option does not override. See Manage Test Harnesses.

Example:

'SaveExternally',true

If 'SaveExternally' is specified, you can specify a location for the external harness SLX file using a comma-separated pair consisting of 'HarnessPath' and a character vector..

Example:

'HarnessPath','C:\MATLAB\SafetyTests'

Use a post create callback function to customize a test harness. The post create callback function executes after the harness is created. For more information, see Customize Test Harnesses.

Example: 'PostCreateCallback','HarnessCustomization'

Use a post rebuild callback function to customize a test harness. The post rebuild callback function executes after the harness rebuild. For more information, see Customize Test Harnesses.

Example: 'PostRebuildCallback','HarnessCustomization'

Option to drive model initialize, reset, and terminate ports with the chosen test harness source, specified as the comma-separated pair consisting of 'ScheduleInitTermReset' and false or true. This option only applies to harnesses created for a block diagram.

Example:

'ScheduleInitTermReset',true

Introduced in R2015a

Was this topic helpful?