sltest.testmanager.TestInput class

Package: sltest.testmanager
Superclasses:

Add or modify test input

Description

Instances of sltest.testmanager.TestInput are sets of signal input data that can be mapped to override the inputs in the System Under Test.

Construction

obj = sltest.testmanager.TestCase.addInput creates a sltest.testmanager.TestInput object for a test case object.

Properties

expand all

Indicates if the input is set to override in the test case, 0 if it is not enabled, and 1 if it is enabled.

This property is read-only.

Sheet and range information for Microsoft® Excel® baseline file, returned as a 1-by-N array, where each row has a Sheet and Range value. Specify Range as shown in the table.

Ways to specify Range Description

'Corner1:Corner2'

Rectangular Range

Specify the range using the syntax 'Corner1:Corner2', where Corner1 and Corner2 are two opposing corners that define the region. For example, 'D2:H4' represents the 3-by-5 rectangular region between the two corners D2 and H4 on the worksheet. The 'Range' name-value pair argument is not case-sensitive, and uses Excel A1 reference style (see Excel help).

Example: 'Range','Corner1:Corner2'

''

Unspecified or Empty

If unspecified, the importing function automatically detects the used range.

Example: 'Range',''

Note: Used Range refers to the rectangular portion of the spreadsheet that actually contains data. The importing function automatically detects the used range by trimming leading and trailing rows and columns that do not contain data. Text that is only white space is considered data and is captured within the used range.

'Row1:Row2'

Row Range

You can identify the range by specifying the beginning and ending rows using Excel row designators. Then readtable automatically detects the used column range within the designated rows. For instance, the importing function interprets the range specification '1:7' as an instruction to read all columns in the used range in rows 1 through 7 (inclusive).

Example: 'Range','1:7'

'Column1:Column2'

Column Range

You can identify the range by specifying the beginning and ending columns using Excel column designators. Then readtable automatically detects the used row range within the designated columns. For instance, the importing function interprets the range specification 'A:F' as an instruction to read all rows in the used range in columns A through F (inclusive).

Example: 'Range','A:F'

'NamedRange'

Excel’s Named Range

In Excel, you can create names to identify ranges in the spreadsheet. For instance, you can select a rectangular portion of the spreadsheet and call it 'myTable'. If such named ranges exist in a spreadsheet, then the importing function can read that range using its name.

Example: 'Range','myTable'

File path of the test input, returned as a character vector.

Example: 'C:\MATLAB\sltestExampleInputs.xlsx'

Evaluated during test case execution in the LoadExternalInput configuration parameter of the System Under Test, specified as a character vector.

Example: 'Acceleration.getElement(1),Acceleration.getElement(2)'

Name of the test input, returned as a character vector.

Example: 'sltestExampleInputs.xlsx'

Mapping status to indicate if the inport mapping was successful. For more information about troubleshooting the mapping status, see Understand Mapping Results.

Example: 'Successfully mapped inputs.'

Methods

addExcelSpecificationAdd a Microsoft Excel sheet to baseline criteria or test case inputs
mapMap test input to system under test
removeRemove test input

Examples

collapse all

You can add data from a Microsoft Excel spreadsheet. The spreadsheet used in this example is located in the example folder.

% 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),0);
map(input(2),0);
Introduced in R2015b