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: [1x1 sltest.testmanager.TestFile] TestPath: 'RollRefTest > Basic Design Test Cases > Requirement 1.3 Test' TestType: 'simulation' RunOnTarget: {[0]} RunOnPlatform: {[Desktop]} Parent: [1x1 sltest.testmanager.TestSuite] Requirements: [0x1 struct] Description: '' Enabled: [1] Tags: [0x0 string]
ans = TestCase with properties: Name: 'RollReference Timeseries Input' TestFile: [1x1 sltest.testmanager.TestFile] TestPath: 'RollRefTest > Logged Data and Coverage > RollReference Timeseries Input' TestType: 'simulation' RunOnTarget: {[0]} RunOnPlatform: {[Desktop]} Parent: [1x1 sltest.testmanager.TestSuite] Requirements: [0x1 struct] Description: '' Enabled: [1] Tags: [0x0 string]
清除测试文件并关闭测试管理器。
sltest.testmanager.clear sltest.testmanager.close
通过搜索文本字符串查找测试用例
此示例显示如何查找具有特定文本字符串的测试用例。
加载测试文件
sltest.testmanager.load('cruiseControlRBTCovTests.mldatx');
查找符合部分描述的测试用例
使用正则表达式名称值参量 RegExp
在测试用例 Description
中搜索 speed
。返回的数组有两个 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
— 测试用例的父级
字符串 | 字符向量 | 测试文件对象 | 测试套件对象 | 小路
测试用例的父级,指定为测试文件对象、测试套件对象、测试用例路径,或者包含测试用例所属的测试文件的名称的字符串或字符向量。如果使用 Parent
名称值参量,则 find
仅在指定父级下的打开的测试文件中搜索。如果您指定一个已关闭的测试文件,则会加载该文件。如果不使用此名称值参量,find
将搜索所有打开的测试文件。
Name
— 测试用例名称
字符串 | 字符向量
要搜索的测试用例的名称,指定为字符串或字符向量。要在测试用例名称中搜索模式,请包含名称值参量 RegExp
=true
。
Enabled
— 是否启用测试用例
true
或 1
| false
或 0
要搜索的测试用例是否启用,指定为数字或逻辑 1
(true
) 或 0
(false
)。如果不指定 Enable
名称值参量,find
将返回启用和禁用的测试用例。
TestFile
— 测试文件的名称
字符串 | 字符向量 | 测试文件对象
测试用例所属的测试文件的名称,指定为字符串、字符向量或测试文件对象。
TestPath
— 测试用例路径
字符串 | 字符向量
测试用例的路径,指定为字符串或字符向量。要在测试路径名称中搜索模式,请包含名称值参量 RegExp
=true
。
示例: TestPath
="myTestFile
> Test Suite 1
> Baseline Test Case
"
TestType
— 测试用例类型
"baseline
" | "equivalence
" | "simulation
"
用例类型,指定为以下值之一:
“
baseline
” — 基线测试“
equivalence
” — 等价检验“
simulation
” — 仿真测试
Description
— 测试用例描述
字符串 | 字符向量
测试用例描述,指定为字符串或字符向量。要在描述中搜索模式,请包含名称值参量 RegExp
=true
。
ReasonForDisabling
— 测试用例被禁用的原因
字符串 | 字符向量
测试用例被禁用的原因,指定为字符串或字符向量。要在 ReasonForDisabling
属性中搜索模式,请包含名称值参量 RegExp
=true
。
Tags
— 测试用例标签
字符串 | 字符向量
测试用例标签,指定为字符串或字符向量。要在 Tag
属性中搜索模式,请包含 RegExp
=true
名称值参量。
RegExp
— 是否使用正则表达式查找测试用例
false
或 0
(默认) | true
或 1
是否使用正则表达式查找测试用例,指定为数字或逻辑 1
(true
) 或 0
(false
)。使用正则表达式在这些名称-值参量中搜索模式:
示例: Name="base",RegExp=true
输出参量
tcArray
— 测试用例
sltest.testmanager.TestCase
对象数组
与指定搜索过滤器匹配的测试用例,以 sltest.testmanager.TestCase
对象数组的形式返回。
版本历史记录
在 R2024a 中推出
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)