% 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');
% Add baseline criteria from file
baseline = addBaselineCriteria(tc,'C:\MATLAB\baseline_API.mat');
使用 Excel 文件作为基线,覆盖测试用例上现有的基线。
% Open the model for this example
openExample('sldemo_absbrake');
% 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);
使用 Excel 文件作为基线,即使 Excel 文件有多张表,也创建一个基线。
% Open the model for this example
openExample('sldemo_absbrake');
% 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);
从 Excel 文件中选择三张表作为基线。对于每个工作表,指定一个单元格范围。
% Open the model for this example
openExample('sldemo_absbrake');
% 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);