This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

createTestForSubsystem

Class: sltest.testmanager.TestFile
Package: sltest.testmanager

Create test harness and test case for subsystem

Syntax

l = createTestForSubsystem(tf,'Subsystem',subsystem)
l = createTestForSubsystem(tf,'Subsystem',subsystem,Name,Value)

Description

l = createTestForSubsystem(tf,'Subsystem',subsystem) creates a harness on the specified subsystem and a baseline test case and test suite in the specified test file. This function also simulates the model and adds the input and the output files to the test case, as MAT-files. For more information, see Generate Tests for a Subsystem.

l = createTestForSubsystem(tf,'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 file, specified as an sltest.testmanager.TestFile object.

Full path of the subsystem, specified as a character vector or string array.

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'

Pairs for MAT-Files and Microsoft Excel Files

expand all

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 'baseline', 'equivalence', or 'simulation'.

Example: 'TestType','equivalence'

Pairs Only 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. Include the file extension .mat.

Example: 'BaselineLocation','C:\MATLAB\baseline_data.mat'

Pairs Only for Microsoft Excel Files

expand all

Option to use Excel format for inputs and, for baseline tests, 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 Excel file to, specified as a character vector or string array. Include the extension .xlsx. If you specify the location, you do not need to also use the 'CreateExcelFile' option.

Example: 'ExcelFileLocation','C:\MATLAB\baseline_data.xlsx'

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

Example: 'Sheet','MySubsysTest'

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 an equivalence test case and test harness for a subsystem, saving the inputs in Excel format.

% Load the model
load_system('sldemo_autotrans');

% Create a test file
tf = sltest.testmanager.TestFile('My Test File');

% Create test from subsystem
createTestForSubsystem(tf,'Subsystem','sldemo_autotrans/ShiftLogic','TestType','equivalence',...
    'CreateExcelFile',true);

Introduced in R2016a