createTestForSubsystem

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

Create test harness and test case for subsystem in test suite

Syntax

harn_tc = createTestForSubsystem(ts,'Subsystem',subsystem)
harn_tc = createTestForSubsystem(ts,'Subsystem',subsystem,Name,Value)

Description

harn_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 for a Component.

harn_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, 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 Pair 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'

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.

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

Returns 0 if the harness and test case are not created, or 1 if the harness and test case are created.

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

Create an equivalence 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','TestType',...
    'equivalence','Simulation1Mode','Normal',...
    'Simulation2Mode','Software-in-the-Loop (SIL)',...
    'CreateExcelFile',true);

Introduced in R2016a