sltest.testmanager.find
Description
specifies options using one or more name-value arguments.tfArray
= sltest.testmanager.find(Name=Value
)
Examples
This example shows how to find all the test cases in an open test file.
Open the test file, which has two test cases.
sltest.testmanager.load("RollRefTest.mldatx");
Find all the test cases in the file and display that two elements are returned in the array.
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
Display the two test objects from the test file.
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]
Clear the test file and close the Test Manager.
sltest.testmanager.clear sltest.testmanager.close
This example shows how to find test cases that have specific text strings.
Load the Test File
sltest.testmanager.load('cruiseControlRBTCovTests.mldatx');
Find Test Cases Matching Part of the Description
Use the regular expression name-value argument, RegExp
, to search for speed
in the test case Description
. The returned array has two TestCase
objects, which both have Test setting the speed
as the description.
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.'
Find Test Cases by Using a Wildcard
This test file has six test cases:
Use the string, r*
to find all test cases with names that contain the letter r
followed by any other character.
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'
Clear the test file and close the Test Manager.
sltest.testmanager.clear sltest.testmanager.close
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: sltest.testmanager.find(Parent="myTestFile.mldatx")
finds
all test cases in the myTestFile.mldatx
file.
Parent of the test case, specified as a test file object, test suite object, test
case path, or string or character vector that contains the name of the test file to
which the test case belongs. If you use the Parent
name-value
argument, find
searches only in open test files under the
specified parent. If you specify a test file that is closed, it is loaded. If you do
not use this name-value argument, find
searches
all open test files.
Name of the test case for which to search, specified as a string or character
vector. To search for a pattern in the test case name, include the name-value argument
RegExp
=true
.
Whether the test case to search for is enabled, specified as a numeric or logical
1
(true
) or 0
(false
). If you do not specify the Enable
name-value argument, find
returns both enabled and disabled test
cases.
Name of the test file to which the test case belongs, specified as a string, character vector, or test file object.
Path of the test case, specified as a string or character vector. To search for a
pattern in the test path name, include the name-value argument
RegExp
=true
.
Example: TestPath
="myTestFile
> Test
Suite 1
> Baseline Test Case
"
Type of the case, specified as one of these values:
"
baseline
" — Baseline test"
equivalence
" — Equivalence test"
simulation
" — Simulation test
Test case description, specified as a string or character vector. To search for a
pattern in the description, include the name-value argument
RegExp
=true
.
Reason that the test case is disabled, specified as a string or character vector.
To search for a pattern in the ReasonForDisabling
property,
include the name-value argument
RegExp
=true
.
Test case tag, specified as a string or character vector. To search for a pattern
in the Tag
property, include the
RegExp
=true
name-value argument.
Whether to find test cases by using regular expressions, specified as a numeric or
logical 1
(true
) or 0
(false
). Use regular expressions to search for a pattern in these
name-value arguments:
Example: Name="base",RegExp=true
Output Arguments
Test cases that match the specified search filters, returned as an array of
sltest.testmanager.TestCase
objects.
Version History
Introduced in 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.
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)