Tag Unit Tests
You can use test tags to group tests into categories and then run tests with specified tags.
Typical test tags identify a particular feature or describe the type of test.
Tag Tests
To define test tags, use a cell array of meaningful character vectors or a string array. For
example, TestTags = {'Unit'} or TestTags = ["Unit","FeatureA"].
- To tag individual tests, use the TestTags method attribute.
- To tag all the tests within a class, use the TestTags class attribute. If you use the
TestTags class attribute in a superclass, tests in the subclasses inherit the tags.
This sample test class, ExampleTagTest, uses the TestTags method attribute to tag
individual tests.
classdef ExampleTagTest < matlab.unittest.TestCase
methods (Test)
function testA (testCase)
% test code
end
end
methods (Test, TestTags = {'Unit'})
function testB (testCase)
% test code
end
function testC (testCase)
% test code
end
end
methods (Test, TestTags = {'Unit','FeatureA'})
function testD (testCase)
% test code
end
end
methods (Test, TestTags = {'System','FeatureA'})
function testE (testCase)
% test code
end
end
end
Tag Unit Tests