sltest.testmanager.find
说明
使用一个或多个名称-值参量指定选项。tfArray = sltest.testmanager.find(Name=Value)
示例
此示例显示如何在打开的测试文件中找到所有测试用例。
打开测试文件,里面有两个测试用例。
sltest.testmanager.load("RollRefTest.mldatx");查找文件中的所有测试用例,并显示数组中返回两个元素。
tcArray = sltest.testmanager.find
tcArray=1×2 TestCase array with properties:
Name
TestFile
TestPath
TestType
RunOnTarget
RunOnPlatform
Parent
Requirements
Description
Enabled
ReasonForDisabling
Tags
numel(tcArray)
ans = 2
显示测试文件中的两个测试对象。
tcArray(1),tcArray(2)
ans =
TestCase with properties:
Name: 'Requirement 1.3 Test'
TestFile: [1×1 sltest.testmanager.TestFile]
TestPath: 'RollRefTest > Basic Design Test Cases > Requirement 1.3 Test'
TestType: 'simulation'
RunOnTarget: {[0]}
RunOnPlatform: {[Desktop]}
Parent: [1×1 sltest.testmanager.TestSuite]
Requirements: [0×1 struct]
Description: ''
Enabled: 1
Tags: [0×0 string]
ans =
TestCase with properties:
Name: 'RollReference Timeseries Input'
TestFile: [1×1 sltest.testmanager.TestFile]
TestPath: 'RollRefTest > Logged Data and Coverage > RollReference Timeseries Input'
TestType: 'simulation'
RunOnTarget: {[0]}
RunOnPlatform: {[Desktop]}
Parent: [1×1 sltest.testmanager.TestSuite]
Requirements: [0×1 struct]
Description: ''
Enabled: 1
Tags: [0×0 string]
清除测试文件并关闭测试管理器。
sltest.testmanager.clear sltest.testmanager.close
此示例显示如何查找具有特定文本字符串的测试用例。
加载测试文件
sltest.testmanager.load('cruiseControlRBTCovTests.mldatx');查找符合部分描述的测试用例
使用正则表达式名称-值参量 RegExp 在测试用例 speed 中搜索 Description。返回的数组有两个 TestCase 对象,它们都以 Test setting the speed 作为描述。
tcArray1 = sltest.testmanager.find(Description='speed',RegExp=true)tcArray1=1×2 TestCase array with properties:
Name
TestFile
TestPath
TestType
RunOnTarget
RunOnPlatform
Parent
Requirements
Description
Enabled
ReasonForDisabling
Tags
tcArray1(1).Name,tcArray1(1).Description
ans = 'Set Speed Test'
ans = 'Test setting the speed.'
tcArray1(2).Name,tcArray1(2).Description
ans = 'Throttle Test'
ans = 'Test setting the speed.'
使用通配符查找测试用例
该测试文件有六个测试用例:

使用字符串 r* 查找名称包含字母 r 且后跟任何其他字符的所有测试用例。
tcArray2 = sltest.testmanager.find(Name='r*',RegExp=true)tcArray2=1×4 TestCase array with properties:
Name
TestFile
TestPath
TestType
RunOnTarget
RunOnPlatform
Parent
Requirements
Description
Enabled
ReasonForDisabling
Tags
tcArray2.Name
ans = 'Brake Test'
ans = 'Increment Test'
ans = 'Decrement Test'
ans = 'Throttle Test'
清除测试文件并关闭测试管理器。
sltest.testmanager.clear sltest.testmanager.close
名称-值参数
以 Name1=Value1,...,NameN=ValueN 的形式指定可选参量对组,其中 Name 是参量名称,Value 是对应的值。名称-值参量必须出现在其他参量之后,但对各个参量对组的顺序没有要求。
示例: sltest.testmanager.find(Parent="myTestFile.mldatx") 查找 myTestFile.mldatx 文件中的所有测试用例。
测试用例的父级,指定为测试文件对象、测试套件对象、测试用例路径,或者包含测试用例所属的测试文件的名称的字符串或字符向量。如果使用 Parent 名称-值参量,则 find 仅在指定父级下的打开的测试文件中搜索。如果您指定一个已关闭的测试文件,则会加载该文件。如果不使用此名称-值参量,find 将搜索所有打开的测试文件。
要搜索的测试用例的名称,指定为字符串或字符向量。要在测试用例名称中搜索模式,请包含名称-值参量 RegExp=true。
要搜索的测试用例是否启用,指定为数字或逻辑 1 (true) 或 0 (false)。如果不指定 Enable 名称-值参量,find 将返回启用和禁用的测试用例。
测试用例所属的测试文件的名称,指定为字符串、字符向量或测试文件对象。
测试用例的路径,指定为字符串或字符向量。要在测试路径名称中搜索模式,请包含名称-值参量 RegExp=true。
示例: TestPath="myTestFile > Test Suite 1 > Baseline Test Case"
用例类型,指定为以下值之一:
baseline- 基线测试equivalence- 等价检验simulation- 仿真测试
测试用例描述,指定为字符串或字符向量。要在描述中搜索模式,请包含名称-值参量 RegExp=true。
测试用例被禁用的原因,指定为字符串或字符向量。要在 ReasonForDisabling 属性中搜索模式,请包含名称-值参量 RegExp=true。
测试用例标签,指定为字符串或字符向量。要在 Tag 属性中搜索模式,请包含 RegExp=true 名称-值参量。
是否使用正则表达式查找测试用例,指定为数字或逻辑 1 (true) 或 0 (false)。使用正则表达式在这些名称-值参量中搜索模式:
示例: Name="base",RegExp=true
输出参量
与指定搜索过滤器匹配的测试用例,以 sltest.testmanager.TestCase 对象数组的形式返回。
版本历史记录
在 R2024a 中推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)