createTestForSubsystem
Class: sltest.testmanager.TestSuite
Package: sltest.testmanager
(Not recommended) Create test harness and test case for subsystem in test suite
sltest.testmanager.TestSuite.createTestForSubsystem
is not
recommended. Use sltest.testmanager.createTestForComponent
instead. For more information,
see Compatibility Considerations.
Syntax
tc = createTestForSubsystem(ts,'Subsystem',subsystem)
tc = createTestForSubsystem(ts,'Subsystem',subsystem,Name,Value)
Description
creates a harness on the specified subsystem and a baseline test case in the specified
test suite. This function also simulates the model and adds the input and the output
files to the test case as MAT-files. files. For more information, see Generate Tests and Test Harnesses for a Model or Components.tc
= createTestForSubsystem(ts
,'Subsystem',subsystem
)
uses additional options specified by one or more tc
= createTestForSubsystem(ts
,'Subsystem',subsystem
,Name,Value
)Name,Value
pair
arguments. Use this syntax to use Microsoft®
Excel® files as input and output files.
Input Arguments
ts
— Test suite
sltest.testmanager.TestSuite
object
Test suite in which to add the new test case, specified as an sltest.testmanager.TestSuite
object.
subsystem
— Subsystem path
character vector | string array
Full path of the subsystem, specified as a character vector or string array. If the subsystem or component is in a Model block, you do not have to include the name of the block in the path. You can specify only the top-level model and system or the component under test.
Example: 'myModel/Controller'
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'CreateExcelFile',true,'Sheet','mysheet'
TopModel
— Model name at top of hierarchy
character vector | string array
Model name at the top of the hierarchy if the subsystem is in a referenced model, specified as a character vector or string array.
Example: 'TopModel','Plant'
TestType
— Test case type
"baseline"
(default) | "equivalence"
| "simulation"
Test case type, specified as one of these strings:
'baseline'
, 'equivalence'
, or
'simulation'
.
Example: 'TestType','equivalence'
UseSubsystemInputs
— Option to simulate model to obtain inputs
true
(default) | false
Option to simulate the model to obtain subsystem inputs to use as inputs in the created test harness, specified as a logical. If this property is true, the test harness uses the subsystem inputs from the model simulation. If this property is false, the test harness does not use the subsystem inputs from the simulation.
Example: 'UseSubsystemInputs',false
Simulation1Mode
— Simulation mode for simulation 1
"Normal"
| "Accelerator"
Simulation mode for simulation 1 of an equivalence test, specified as
either "Normal"
or "Accelerator"
.
If you do not specify a simulation mode, the mode of the system under
test is used.
Example: "Simulation1Mode","Normal"
Simulation2Mode
— Simulation mode for simulation 2
string | character vector
Simulation mode for simulation 2 of an equivalence test, specified as one of these values:
"Normal"
"Accelerator"
"Rapid Accelerator"
"Software-in-the-Loop (SIL)"
"Processor-in-the-Loop (PIL)"
If you do not specify a simulation mode, the mode of the
system under test is used. If TestType
is
equivalence
and
Simulation2Mode
is
Software-in-the-Loop (SIL)
, an extra test harness
is created in addition to the test case and test harness.
Example: "Simulation2Mode","Software-in-the-Loop
(SIL)"
InputsLocation
— Input filename and path for MAT-files
character vector | string array
Input filename and location for MAT-files, specified as a character
vector or string array. Include the file extension
.mat
.
Example: 'InputsLocation','C:\MATLAB\inputs_data.mat'
BaselineLocation
— Baseline file location
character vector | string array
Filename and path to save baseline data to, specified as a character
vector or string. Include the file extension
.mat
.
Example: 'BaselineLocation','C:\MATLAB\baseline_data.mat'
CreateExcelFile
— Use Excel format for inputs and outputs
false
(default) | true
Option to use Excel format
for inputs and, for baseline tests only, outputs, specified as
true
or false
. If you use the
'ExcelFileLocation
argument to specify the
filename and location, you do not need to also use
'CreateExcelFile
.
Example: 'CreateExcelFile',true
ExcelFileLocation
— Name and location for Excel file
character vector | string array
Filename and path to save the Excel file to, specified as a character vector or
string array. Include the extension .xlsx
. If you
specify a location, you do not need to also use the
'CreateExcelFile'
option.
Note
If SLDVTestGeneration
is
true
and
HarnessSource
is "Signal
Editor"
, you cannot save data to an Excel
file.
Example: 'ExcelFileLocation','C:\MATLAB\baseline_data.xlsx'
Sheet
— Name of Excel sheet to save data to
character vector | string array
Name of the sheet to save Excel data to, specified as a character vector or string array.
Example: 'Sheet','MySubsysTest'
SLDVTestGeneration
— Whether to generate tests using Simulink® Design Verifier™
false
(default) | true
Whether to generate tests using Simulink Design Verifier, specified as a logical. If this property is true, Simulink Design Verifier generates the tests to include in the test suite.
Note
To generate tests from Simulink Design Verifier, the system under test must be an atomic subsystem.
Example: 'SLDVTestGeneration',true
HarnessSource
— Input source block for the harness
"Inport"
(default) | "Signal Editor"
Input source block for the test harness, specified as
"Inport"
or "Signal
Editor"
.
Example: "HarnessSource","Signal
Editor"
Output Arguments
tc
— Test case
sltest.testmanager.testcase
object
Test case, returned as an sltest.testmanager.testcase
object.
Examples
Create Test for a Subsystem
Create a baseline test case and test harness for a subsystem, then save the inputs in Excel format.
% Load the model openExample('SILBlock'); % Create a test file and get the test suite tf = sltest.testmanager.TestFile('My B2B Test File'); ts = getTestSuites(tf); % Create test from subsystem createTestForSubsystem(ts,'Subsystem',... 'SILBlock/Controller',... 'CreateExcelFile',true);
Version History
Introduced in R2016aR2020b: sltest.testmanager.TestSuite.createTestForSubsystem
not recommended
sltest.testmanager.TestFile.createTestForSubsystem
is not
recommended. Use sltest.testmanager.createTestForComponent
instead. This function
lets you create test cases for models, in addition to subsystems.
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)