addBaselineCriteria
类: sltest.testmanager.TestCase
命名空间: sltest.testmanager
将基线准则添加到测试用例
语法
说明
输入参数
tc
— 测试用例
sltest.testmanager.TestCase
对象
您想要添加基线准则的测试用例,指定为 sltest.testmanager.TestCase
对象。
file
— Excel、MAT 或 SDI MLDATX 文件名和路径
字符向量
基线准则文件的文件和路径名,指定为字符向量。您可以指定 MAT 文件、Simulation Data Inspector MLDATX 文件或 Microsoft Excel 文件。
示例: 'C:\MATLAB\baseline_API.mat'
excel
— Excel 文件名和路径
字符向量
用作基线准则的 Excel 文件的文件和路径名,指定为字符向量。
示例: 'C:\MATLAB\baseline.xlsx'
sheets
— 要添加的 Excel 工作表的名称
字符向量 | 字符串 | 字符串数组
要添加的 Excel 文件中的工作表的名称,指定为字符向量、字符串或字符串数组。
示例: 'signals'
, ["Heater","Plant"]
名称-值参数
将可选的参量对组指定为 Name1=Value1,...,NameN=ValueN
,其中 Name
是参量名称,Value
是对应的值。名称-值参量必须出现在其他参量后,但参量对组的顺序无关紧要。
在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name
引起来。
示例: 'Ranges','B1:C4','RefreshIfExists',false
Ranges
— 工作表中的单元格范围
字符向量 | 字符串 | 字符串数组
您添加为基线准则的工作表中的单元格范围,指定为字符向量、字符串或字符串数组。您指定的范围必须与您指定的工作表相对应。例如,如果指定一张工作表,则指定一个范围。如果指定工作表的元胞数组,则 'Ranges'
元胞数组中的每个值必须与 'Sheets'
元胞数组中的一个工作表相对应。指定一个空范围以使用整个工作表。
示例: 'B2:C30'
, "D2:E30"
, ["B2:C30", "D2:E30", "B2:C30"]
, ["B2:C30","","D2:E30"]
RefreshIfExists
— 替换基线准则
false
(默认) | true
用于替换测试用例基线准则,指定为布尔值。如果测试用例已经有基线准则,则使用 false
返回错误,即防止覆盖基线。使用 true
添加基线准则,替换现有的基线。
SeparateBaselines
— 指定单独的基线
true (默认) | false
选择使用 'Sheets'
参量指定的每个工作表作为单独的基线,指定为 true
或 false
。
输出参量
base
— 基线准则
sltest.testmanager.BaselineCriteria
对象 | sltest.testmanager.BaselineCriteria
对象数组
添加到测试用例的基线准则,以 sltest.testmanager.BaselineCriteria
对象或 sltest.testmanager.BaselineCriteria
对象数组的形式返回。
示例
将基线准则添加到测试用例
% 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');
使用 Microsoft 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','RefreshIfExists',true);
从 Microsoft Excel 文件添加一条基线
使用 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);
版本历史记录
在 R2015b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)