Main Content

本页采用了机器翻译。点击此处可查看英文原文。

getBaselineRun

类: sltest.testmanager.TestCaseResult
命名空间: sltest.testmanager

获取测试用例基线数据集

语法

baseline = getBaselineRun(result)

说明

baseline = getBaselineRun(result) 获取测试用例使用的基线数据集,属于测试用例结果对象。仅当在基线准则部分下的测试用例中选中 Save baseline data in test result 复选框时,基线数据集才会与测试用例结果一起保存。

为了在测试用例结果中记录基线数据,必须将 SaveBaselineRunInTestResult 测试用例属性设置为 true

setProperty(testcase,'SaveBaselineRunInTestResult',true);

输入参数

全部展开

从中获取基线数据集的测试用例结果,指定为 sltest.testmanager.TestCaseResult 对象。

输出参量

全部展开

测试用例基线数据集,以 Simulink.sdi.Run 对象形式返回。如果测试用例中未选中 Save baseline data in test result 复选框,则该函数返回一个空数组。

示例

全部展开

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

版本历史记录

在 R2016a 中推出