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.

addBaselineCriteria

Class: sltest.testmanager.TestCase
Package: sltest.testmanager

Add baseline criteria to test case

Syntax

base = addBaselineCriteria(tc,file)
base = addBaselineCriteria(tc,file,'RefreshIfExists',true)
base = addBaselineCriteria(tc,excel,'SeparateBaselines',false)
base = addBaselineCriteria(tc,excel,'Sheets',sheets,Name,Value)

Description

example

base = addBaselineCriteria(tc,file) adds a MAT-file or Microsoft® Excel® file as baseline criteria to a baseline test case. If file is an Excel file that has multiple sheets, each is added to the test case as a separate baseline set.

example

base = addBaselineCriteria(tc,file,'RefreshIfExists',true) adds the baseline criteria to the test case, replacing the baseline criteria if the test case already had one.

example

base = addBaselineCriteria(tc,excel,'SeparateBaselines',false) adds all sheets in the Excel file as a single baseline set.

example

base = addBaselineCriteria(tc,excel,'Sheets',sheets,Name,Value) specifies the sheets from the Excel to include in the baseline criteria and uses additional options specified by one or more Name,Value pair arguments.

Input Arguments

expand all

Test case that you want to add the baseline criteria to, specified as an sltest.testmanager.TestCase object.

File and path name of the baseline criteria file, specified as a character vector. You can specify a MAT-file or a Microsoft Excel file.

Example: 'C:\MATLAB\baseline_API.mat', 'C:\MATLAB\baseline.xlsx'

File and path name of the Excel file to use as the baseline criteria, specified as a character vector.

Example: 'C:\MATLAB\baseline.xlsx'

Names of sheets from Excel file to add, specified as a character vector, string, or array of strings.

Example: 'signals', ["Heater","Plant"]

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: 'Ranges','B1:C4','RefreshIfExists',false

Ranges of cells from the sheets that you add as baseline criteria, specified as a character vector, a string, or an array of strings. The ranges you specify must correspond to the sheets you specify. For example, if you specify one sheet, specify one range. If you specify a cell array of sheets, each value in the 'Ranges' cell array must correspond to a sheet in the 'Sheets' cell array. Specify an empty range to use the entire sheet.

Example: 'B2:C30', "D2:E30", ["B2:C30", "D2:E30", "B2:C30"], ["B2:C30","","D2:E30"]

Option to replace the test case baseline criteria, specified as a Boolean. Use false to return an error if the test case already has baseline criteria, that is, to prevent overwriting the baseline. Use true to add the baseline criteria, replacing the existing baseline.

Option to use each sheet in specified by the 'Sheets' argument as a separate baseline, specified as true or false.

Output Arguments

expand all

Baseline criteria added to the test case, returned as an sltest.testmanager.BaselineCriteria object or an array of sltest.testmanager.BaselineCriteria objects.

Examples

expand all

% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('API Test File');
ts = createTestSuite(tf,'API Test Suite');
tc = createTestCase(ts,'baseline','Baseline API Test Case');

% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');

% Add baseline criteria from file
baseline = addBaselineCriteria(tc,'C:\MATLAB\baseline_API.mat');

Use an Excel file as baseline, overwriting the existing baseline on the test case.

% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('Excel Test File');
ts = createTestSuite(tf,'Excel Test Suite');
tc = createTestCase(ts,'baseline','Baseline Excel Test Case');

% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');

% Add baseline criteria from file
baseline = addBaselineCriteria(tc,'C:\MATLAB\myexcel.xlsx','RefreshIfExists',true);

Use an Excel file as baseline, creating one baseline even if the Excel file has multiple sheets.

% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('Excel Test File');
ts = createTestSuite(tf,'Excel Test Suite');
tc = createTestCase(ts,'baseline','Baseline Excel Test Case');

% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');

% Add baseline criteria from file
baseline = addBaselineCriteria(tc,'C:\MATLAB\myexcel.xlsx','SeparateBaselines',false);

Select three sheets from an Excel file to use as the baseline. For each sheet, specify a range of cells.

% Create the test file, test suite, and test case structure
tf = sltest.testmanager.TestFile('Excel Test File');
ts = createTestSuite(tf,'Excel Test Suite');
tc = createTestCase(ts,'baseline','Baseline Excel Test Case');

% Remove the default test suite
tsDel = getTestSuiteByName(tf,'New Test Suite 1');
remove(tsDel);

% Assign the system under test to the test case
setProperty(tc,'Model','sldemo_absbrake');

% Create sheets and ranges arrays
sheets = ["HotTemp", "ColdTemp", "NominalTemp"];
ranges = ["B2:C30", "D2:E30", "B2:C30"];

% Add baseline criteria from file, using the sheets and cell ranges specified
baseline = addBaselineCriteria(tc,'C:\MATLAB\myexcel.xlsx','Sheets',sheets,'Ranges',ranges);

Introduced in R2015b