padv.builtin.query.FindTestCasesForModel Class
Namespace: padv.builtin.query
Superclasses: padv.Query
Query for finding test cases for model
Description
This class requires CI/CD Automation for Simulink Check.
The padv.builtin.query.FindTestCasesForModel
class provides a query that
can return the test cases associated with a model, including test cases associated with
subsystem
references.
You can automatically include or exclude certain test cases by using the optional name-value
arguments.
You can use this query in your process model to find test cases for your tasks to iterate over or use as inputs.
The padv.builtin.query.FindTestCasesForModel
class is a handle
class.
Creation
Description
creates a query for finding the test cases associated with a model, including test cases
associated with subsystem references.query
= padv.builtin.query.FindTestCasesForModel()
sets certain properties using one or more name-value arguments. For example,
query
= padv.builtin.query.FindTestCasesForModel(Name=Value
)padv.builtin.query.FindTestCasesForModel(Tags = "TagA")
creates a
query object for finding test cases that use the test case tag
"TagA"
.
Note
If you use this query as an input query and specify non-empty values for
IncludeLabel
, ExcludeLabel
,
IncludePath
, or ExcludePath
, your task
results can unexpectedly become outdated. If you see this behavior, consider using a
different query, like padv.builtin.query.FindArtifacts
, instead. For more information and a list
of queries that are not impacted by this limitation, see Other Limitations.
The padv.builtin.query.FindTestCasesForModel
class also has other properties, but you cannot set
those properties during query creation.
Input 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: query = padv.builtin.query.FindTestCasesForModel(Tags =
"TagA")
ExcludeLabel
— Exclude artifacts with specific project label
cell array
Exclude artifacts with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.
Example: {"Category","Label"}
Data Types: cell
ExcludePath
— Exclude artifacts where path contains specific text
string | character vector
Exclude artifacts where the path contains specific text, specified as a string or a character vector.
Example: "Control"
Data Types: string
IncludeLabel
— Find artifacts with specific project label
cell array
Find artifacts with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.
Example: {"Category","Label"}
Data Types: cell
IncludePath
— Find artifacts where path contains specific text
string
Find artifacts where the path contains specific text, specified as a string.
Example: "Control"
Data Types: string
Name
— Unique identifier for query
string
Unique identifier for query, specified as a string.
Example: "FindMyTestCases"
Data Types: string
Parent
— Initial query run before iteration query
"padv.builtin.query.FindModels"
(default) | padv.Query
object | Name
of padv.Query
object
Initial query run before iteration query, specified as either a
padv.Query
object or the Name
of a
padv.Query
object. When you specify a padv.Query
object as the iteration query for a task, the Parent
query is
the initial query that the build system runs before running the specified iteration
query.
The build system ignores the Parent
query when you specify
a query as an input query or dependency query for a task.
For information on how to improve Process Advisor load times by sharing query instances across your process model, see Best Practices for Process Model Authoring.
Example: padv.builtin.query.FindModels
Example: padv.builtin.query.FindModels(IncludePath =
"Control")
Tags
— Only include test cases with specific test case tags
string | character vector | cell array
Only include test cases that use a specific test case tag or tags, specified as a string, a character vector, or cell array.
Example: "TagA"
Example: {"tag1","tag2"}
Data Types: char
| string
| cell
Properties
IncludeLabel
— Find artifacts with specific project label
cell array
Find artifacts with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.
Example: {"Category","Label"}
Data Types: cell
ExcludeLabel
— Exclude artifacts with specific project label
cell array
Exclude artifacts with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.
Example: {"Category","Label"}
Data Types: cell
IncludePath
— Find artifacts where path contains specific text
string
Find artifacts where the path contains specific text, specified as a string.
Example: "Control"
Data Types: string
ExcludePath
— Exclude artifacts where path contains specific text
string | character vector
Exclude artifacts where the path contains specific text, specified as a string or a character vector.
Example: "Control"
Data Types: string
Tags
— Only include test cases with specific test case tags
string | character vector | cell array
Only include test cases that use a specific test case tag or tags, specified as a string, a character vector, or cell array.
Example: "TagA"
Example: {"tag1","tag2"}
Data Types: char
| string
| cell
Title
— Query title
"All test cases for a given model"
(default) | string | character vector
Query title, specified as a string or a character vector.
Example: "Find my test cases"
Data Types: string
DefaultArtifactType
— Default artifact type returned by query
"sl_test_case"
(default) | ...
Default artifact type returned by the query, specified as one or more of the values in this table. To specify multiple values, use an array.
Category | Artifact Type | Description |
---|---|---|
MATLAB® | "m_class" | MATLAB class |
"m_file" | MATLAB file | |
"m_func" | MATLAB function | |
"m_method" | MATLAB class method | |
"m_property" | MATLAB class property | |
Model Advisor | "ma_config_file" | Model Advisor configuration file |
"ma_justification_file" | Model Advisor justification file | |
Process Advisor | "padv_dep_artifacts" | Related artifacts that current artifact depends on |
"padv_output_file" | Process Advisor output file | |
Project | "project" | Current project file |
Requirements | "mwreq_item" | Requirement (since R2024b) |
| Requirement (for R2024a and earlier) | |
"sl_req_file" | Requirement file | |
"sl_req_table" | Requirements Table | |
Stateflow® | "sf_chart" | Stateflow chart |
"sf_graphical_fcn" | Stateflow graphical function | |
"sf_group" | Stateflow group | |
"sf_state" | Stateflow state | |
"sf_state_transition_chart" | Stateflow state transition chart | |
"sf_truth_table" | Stateflow truth table | |
Simulink® | "sl_block_diagram" | Block diagram |
"sl_data_dictionary_file" | Data dictionary file | |
"sl_embedded_matlab_fcn" | MATLAB function | |
"sl_block_diagram" | Block diagram | |
"sl_library_file" | Library file | |
"sl_model_file" | Simulink model file | |
"sl_protected_model_file" | Protected Simulink model file | |
"sl_subsystem" | Subsystem | |
"sl_subsystem_file" | Subsystem file | |
System Composer™ | "zc_block_diagram" | System Composer architecture |
"zc_component" | System Composer architecture component | |
"zc_file" | System Composer architecture file | |
Tests | "harness_info_file" | Harness info file |
"sl_harness_block_diagram" | Harness block diagram | |
"sl_harness_file" | Test harness file | |
"sl_test_case" | Simulink Test™ case | |
"sl_test_case_result" | Simulink Test case result | |
"sl_test_file" | Simulink Test file | |
"sl_test_iteration" | Simulink Test iteration | |
"sl_test_iteration_result" | Simulink Test iteration result | |
"sl_test_report_file" | Simulink Test result report | |
"sl_test_result_file" | Simulink Test result file | |
"sl_test_resultset" | Simulink Test result set | |
"sl_test_seq" | Test Sequence | |
"sl_test_suite" | Simulink Test suite | |
"sl_test_suite_result" | Simulink Test suite result |
Example: "sl_test_case"
Example: ["sl_test_case" "other_file"]
Parent
— Initial query run before iteration query
"padv.builtin.query.FindModels"
(default) | padv.Query
object | Name
of padv.Query
object
Initial query run before iteration query, specified as either a
padv.Query
object or the Name
of a
padv.Query
object. When you specify a padv.Query
object as the iteration query for a task, the Parent
query is the
initial query that the build system runs before running the specified iteration
query.
The build system ignores the Parent
query when you specify a
query as an input query or dependency query for a task.
For information on how to improve Process Advisor load times by sharing query instances across your process model, see Best Practices for Process Model Authoring.
Example: padv.builtin.query.FindModels
Example: padv.builtin.query.FindModels(IncludePath =
"Control")
Name
— Unique identifier for query
string
Unique identifier for query, specified as a string.
Example: "FindMyTestCases"
Data Types: string
ShowFileExtension
— Show file extensions for returned artifacts
0
(false
) | 1
(true
)
Show file extensions in the Alias
property of returned
artifacts, specified as a numeric or logical 1
(true
) or 0
(false
). The
Alias
property controls the display name for the artifact in the
Tasks column in Process Advisor.
By default, queries strip file extensions from the Alias
property of each task iteration artifact. To show file extensions for
all artifacts in the
Tasks column, select the project setting Show file
extensions. To keep file extensions in the results for a specific query,
specify the query property ShowFileExtension
as
true
.
Example: true
Data Types: logical
SortArtifacts
— Setting for automatically sorting artifacts by address
true
or 1
(default) | false
or 0
Setting for automatically sorting artifacts by address, specified as a numeric or
logical 1
(true
) or 0
(false
). When a query returns artifacts, the artifacts should be in
a consistent order. By default, the build system sorts artifacts by the artifact
address.
Alternatively, you can sort artifacts in a different order by overriding the
internal sortArtifacts
method in a subclass that defines a custom sort
behavior. For an example, see Sort Artifacts in Specific Order.
The build system automatically calls the sortArtifacts
method when
using the process model. The sortArtifacts
method expects two input
arguments: a padv.Query
object and a list of
padv.Artifact
objects returned by the run
method.
The sortArtifacts
method should return a list of sorted
padv.Artifact
objects.
Example: SortArtifacts = false
Data Types: logical
FunctionHandle
— Handle to function that function-based query runs
function_handle
Handle to the function that a function-based query
runs, specified as
a function_handle
.
If you define your query functionality inside a function and you or the build system
call run
on the query, the query runs the function specified by the
function_handle
.
The built-in queries are defined inside classes and do not use the
FunctionHandle
.
Example: FunctionHandle = @FunctionForQuery
Data Types: function_handle
Methods
Specialized Public Methods
This class overrides the following inherited methods.
run | Run query to find the artifacts that meet the criteria specified by the query. The query returns a Note You do not need to manually invoke this method inside your process
model. The build system automatically invokes the
The function artifacts = run(obj,iterationArtifact) ... end |
Examples
Only Run Tests for Test Cases with Specific Tags
You can use the FindTestCasesForModel
query in your
process model to find test cases for your tasks to iterate over
(IterationQuery
) or use as inputs
(addInputQueries
). For example, suppose that you want the
Run Tests task to only run on test cases that use the specific test
case tag TagA
. You can use the built-in query
padv.builtin.query.FindTestCasesForModel
to find the test cases and
the Tags
input argument to have the query only return test cases that
use the specified test case tag. Suppose you have a project that contains test cases that
use the test case tags TagA
and TagB
.
Consider the following process model.
function processmodel(pm) % Defines the project's processmodel arguments pm padv.ProcessModel end % Run Tests for TagA milTaskA = addTask(pm,padv.builtin.task.RunTestsPerTestCase(Name = "RunTestsForTagA")); milTaskA.Title = "Run Tests for TagA"; milTaskA.IterationQuery = padv.builtin.query.FindTestCasesForModel(Tags = "TagA"); % Run Tests for TagB milTaskB = pm.addTask(padv.builtin.task.RunTestsPerTestCase(Name = "RunTestsForTagB")); milTaskB.Title = "Run Tests for TagB"; milTaskB.IterationQuery = padv.builtin.query.FindTestCasesForModel(Tags = "TagB"); end
FindTestCasesForModel
as the
iteration query for the built-in task RunTestsPerTestCase
to have the
task only run for each test case that uses the specified test case tag. Note that since
this process model uses multiple instances of the task
RunTestsPerTestCase
, the code specifies unique Name
values for each task.In Process Advisor, view the updated Tasks by clicking Refresh Tasks and switching to the Project view. When you run the tasks, the tasks only run on the test cases with the specified test case tags. The test case names appear under the name of the model associated with the test case.
Capabilities and Limitations
This table identifies functionality that is supported by the query.
Functionality | Supported? |
---|---|
Input query for task | Yes. |
Iteration query for task | Yes. |
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)