Class: sltest.testmanager.TestInput
Package: sltest.testmanager
Map test input to system under test
map(input,Name,Value)
map(
maps the test input data input
,Name
,Value
)input
to the
system under test.
input
— Test inputsltest.testmanager.TestInput
objectThe test input to map, specified as a sltest.testmanager.TestInput
object.
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
.
'Mode',4,'CustomFunction','mapfcn'
'Mode'
— Mapping mode0
| 1
| 2
| 3
| 4
Mapping mode, specified as the
comma-separated pair consisting of
'mode'
and an integer
corresponding to the desired mapping mode:
0
— Block
name
1
— Block
path
2
— Signal
name
3
— Port order
(index)
4
— Custom
For more information on mapping modes, see Map Root Inport Signal Data.
Example: 'Mode',2
'CustomFunction'
— Custom mapping function nameName of function used for custom mapping,
specified as the comma-separated pair consisting
of 'customFunction'
and a
character vector. This argument is optional and
valid only when mode
is set
to 4
.
Example: 'CustomFunction','mapfcn'
'CompileModel'
— Model compilation for mappingtrue
(default) | false
Option to compile or not compile the model
when performing input mapping, specified as the
comma-separated pair consisting of
'CompileModel'
and
false
or
true
.
Example: 'CompileModel',false
This example maps data from a Microsoft® Excel® spreadsheet to a test case.
% Load example model open_system('sltestExcelExample'); % Create new test file tf = sltest.testmanager.TestFile('C:\MATLAB\input_test_file.mldatx'); % Get test suite object ts = getTestSuites(tf); % Get test case object tc = getTestCases(ts); % Add the example model as the system under test setProperty(tc,'Model','sltestExcelExample'); % Add Excel data to Inputs section % Specify two sheets to add: Acceleration and Braking input_path = fullfile(matlabroot,'toolbox','simulinktest',... 'simulinktestdemos','sltestExampleInputs.xlsx'); input = addInput(tc,input_path,'Sheets',["Acceleration","Braking"]); % Map the input signal for the sheets by block name map(input(1),'Mode',0); map(input(2),'Mode',0);