Dynamically Filtered Tests
In this section...
“Test Methods” on page 33-142
“Method Setup and Teardown Code” on page 33-145
“Class Setup and Teardown Code” on page 33-147
Assumption failures produce filtered tests. In the matlab.unittest.TestResult class,
such a test is marked Incomplete.
Since filtering test content through the use of assumptions does not produce test failures,
it has the possibility of creating dead test code. Avoiding this requires monitoring of
filtered tests.
Test Methods
If an assumption failure is encountered inside of a TestCase method with the Test
attribute, the entire method is marked as filtered, but MATLAB runs the subsequent Test
methods.
The following class contains an assumption failure in one of the methods in the Test
block.
classdef ExampleTest < matlab.unittest.TestCase
methods(Test)
function testA(testCase)
testCase.verifyTrue(true)
end
function testB(testCase)
testCase.assumeEqual(0,1)
% remaining test code is not exercised
end
function testC(testCase)
testCase.verifyFalse(true)
end
end
end
Since the testB method contains an assumption failure, when you run the test, the
testing framework filters that test and marks it as incomplete. After the assumption
33 Unit Testing