Main Content

createTestForSubsystem

Class: sltest.testmanager.TestSuite
Package: sltest.testmanager

(To be removed) Create test harness and test case for subsystem in test suite

sltest.testmanager.TestSuite.createTestForSubsystem will be removed in a future release. 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

tc = createTestForSubsystem(ts,'Subsystem',subsystem) 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 Component or Model.

tc = createTestForSubsystem(ts,'Subsystem',subsystem,Name,Value) uses additional options specified by one or more Name,Value pair arguments. Use this syntax to use Microsoft® Excel® files as input and output files.

Input Arguments

expand all

Test suite in which to add the new test case, specified as an sltest.testmanager.TestSuite object.

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: 'f14/Controller'

Name-Value Arguments

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.

Example: 'CreateExcelFile',true,'Sheet','mysheet'

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'

Test case type, specified as one of these strings: 'baseline', 'equivalence', or 'simulation'.

Example: 'TestType','equivalence'

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

Pairs for Equivalence Testing

expand all

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"

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)"

Pairs for MAT-Files

expand all

Input file name 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'

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

Pairs for Microsoft Excel Files

expand all

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 file name and location, you do not need to also use 'CreateExcelFile.

Example: 'CreateExcelFile',true

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

Name of the sheet to save Excel data to, specified as a character vector or string array.

Example: 'Sheet','MySubsysTest'

Pairs for Simulink Design Verifier

expand all

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

Input source block for the test harness, specified as "Inport" or "Signal Editor".

Example: "HarnessSource","Signal Editor"

Output Arguments

expand all

Test case, returned as an sltest.testmanager.testcase object.

Examples

expand all

Create a baseline test case and test harness for a subsystem, then save the inputs in Excel format.

% Load the model
load_system('rtwdemo_sil_block');

% 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',...
    'rtwdemo_sil_block/Controller',...
    'CreateExcelFile',true);

Compatibility Considerations

expand all

Not recommended starting in R2020b

Introduced in R2016a