Package: sltest.testmanager
Add or modify test input
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.
creates a obj = sltest.testmanager.TestCase.addInputsltest.testmanager.TestInput object for a test case
object.
Active — Enabled indicator0 | 1Indicates if the input is set to override in the test case, 0 if
it is not enabled, and 1 if it is enabled.
GetAccess | public |
SetAccess | public |
Dependent | true |
NonCopyable | true |
Data Types: logical
ExcelSpecifications — Sheet and range information for Excel baseline fileSheet 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 |
|---|---|
Rectangular Range | Specify the range using the syntax
Example:
|
Unspecified or Empty | If unspecified, the importing function automatically detects the used range. Example:
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. |
Row Range | You can identify the range by specifying the beginning and
ending rows using Excel row designators. Then Example:
|
Column Range | You can identify the range by specifying the beginning and
ending columns using Excel column designators. Then
Example:
|
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 Example:
|
GetAccess | public |
SetAccess | public |
Dependent | true |
NonCopyable | true |
Data Types: array
FilePath — File pathFile path of the test input, returned as a character vector.
Example: 'C:\MATLAB\sltestExampleInputs.xlsx'
GetAccess | public |
SetAccess | private |
Dependent | true |
NonCopyable | true |
Data Types: char
InputString — InputInput 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)'
GetAccess | public |
SetAccess | public |
Dependent | true |
NonCopyable | true |
Data Types:
Name — Test input nameName of the test input, returned as a character vector.
Example: 'sltestExampleInputs.xlsx'
GetAccess | public |
SetAccess | private |
Dependent | true |
NonCopyable | true |
Data Types: char
MappingStatus — Input mapping statusMapping 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.'
GetAccess | public |
SetAccess | private |
Dependent | true |
NonCopyable | true |
Data Types: char
addExcelSpecification | Add a Microsoft Excel sheet to baseline criteria or test case inputs |
map | Map test input to system under test |
remove | Remove test input |
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);
You have a modified version of this example. Do you want to open this example with your edits?