Main Content

sltest.testmanager.TestInput class

Package: sltest.testmanager

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.

The sltest.testmanager.TestInput class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

example

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.

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: logical

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 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'

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types: array

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

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

Attributes:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

Data Types: char

Input 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)'

Attributes:

GetAccess
public
SetAccess
public
Dependent
true
NonCopyable
true

Data Types:

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

Example: 'sltestExampleInputs.xlsx'

Attributes:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

Data Types: char

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.'

Attributes:

GetAccess
public
SetAccess
private
Dependent
true
NonCopyable
true

Data Types: char

Methods

expand all

Examples

collapse all

This example shows how to add data from a Microsoft® Excel® spreadsheet and map it to a test case. Only the two sheets that have data are added and mapped.

Load the Example Model

open_system('sltestExcelExample');

Create a New Test File

tf = sltest.testmanager.TestFile('input_test_file.mldatx');

Get the Test Suite and Test Case Objects

ts = getTestSuites(tf);
tc = getTestCases(ts);

Add the Example Model as the System Under Test

setProperty(tc,'Model','sltestExcelExample');

Add Excel® Data to Inputs Section and Specify Sheets to Add

excelfile = 'sltestExampleInputs.xlsx';
input = addInput(tc,excelfile,'Sheets',["Acceleration","Braking"]);

Map the Input Signal for the Sheets by Block Name

map(input(1),0);
map(input(2),0);

Version History

Introduced in R2015b