matlab.unittest.selectors.HasTag 类
命名空间: matlab.unittest.selectors
根据测试标记选择 TestSuite
数组元素
描述
matlab.unittest.selectors.HasTag
类提供用于根据测试标记过滤测试套件的选择器。
构造
selector = matlab.unittest.selectors.HasTag
创建一个选择器,用于选择任何标记的 TestSuite
数组元素。
selector = matlab.unittest.selectors.HasTag(
创建一个选择器,用于选择具有指定的测试标记的 tag
)TestSuite
数组元素。您可以将 tag
指定为字符串标量、字符向量或 matlab.unittest.constraints.Constraint
对象。如果 tag
是字符串标量或字符向量,则测试框架创建 IsEqualTo
约束来选择用指定值标记的 Test
元素。
对于要包括在经过过滤的测试套件中的 Test
元素,Test
元素必须使用指定的字符串标量或字符向量或者满足指定约束的值进行标记。
输入参量
属性
复制语义
值。要了解值类如何影响复制操作,请参阅复制对象。
示例
备选方法
使用 HasTag
选择器能实现最大的灵活性,可以根据标记创建测试套件。您也可以在创建测试套件时使用 Tag
名称-值参量过滤测试套件。例如:
s = matlab.unittest.TestSuite.fromClass(?ExampleTest,"Tag","Unit");
您还可以使用 Tag
名称-值参量和 runtests
函数来选择和运行标记的测试。例如:
runtests("ExampleTest.m","Tag","Unit");
版本历史记录
在 R2015a 中推出