Main Content

getBaselineRun

Class: sltest.testmanager.TestCaseResult
Namespace: sltest.testmanager

Get test case baseline dataset

Syntax

baseline = getBaselineRun(result)

Description

baseline = getBaselineRun(result) gets the baseline dataset used in a test case, which belongs to the test case results object. The baseline dataset is saved with the test case result only if the Save baseline data in test result check box is selected in the test case under the Baseline Criteria section.

To record the baseline data in the test case result, you must set the SaveBaselineRunInTestResult test case property to true:

setProperty(testcase,'SaveBaselineRunInTestResult',true);

Input Arguments

expand all

Test case results to get baseline dataset from, specified as a sltest.testmanager.TestCaseResult object.

Output Arguments

expand all

Test case baseline dataset, returned as a Simulink.sdi.Run object. If the Save baseline data in test result check box is not selected in the test case, then the function returns an empty array.

Examples

expand all

% Open the model for this example
openExample('sldemo_absbrake');

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

% Capture the baseline criteria and record baseline
baseline = captureBaselineCriteria(tc,'baseline_API.mat',true);
setProperty(tc,'SaveBaselineRunInTestResult',true);

% Test a new model parameter by overriding it in the test case
% parameter set
ps = addParameterSet(tc,'Name','API Parameter Set');
po = addParameterOverride(ps,'m',55);

% Set the baseline criteria tolerance for one signal
sc = getSignalCriteria(baseline);
sc(1).AbsTol = 9;

% Run the test case and return an object with results data
resultsObj = run(tc);

% Get test case result
tcr = getTestCaseResults(resultsObj);

% Get the baseline run dataset
baselineOut = getBaselineRun(tcr);

Version History

Introduced in R2016a