addTeardown
Class: matlab.unittest.TestCase
Namespace: matlab.unittest
Dynamically add teardown code to test case
Description
addTeardown(
registers the teardown code testCase
,teardownFcn
)teardownFcn
with the test case. To
dynamically run teardown code when tests run, use addTeardown
within a
Test
method, TestMethodSetup
method, or
TestClassSetup
method. The timing and frequency of the teardown actions
depend on the scope in which you call the method:
Test
method —teardownFcn
runs after the current test.TestMethodSetup
method —teardownFcn
runs after each test in the test class.TestClassSetup
method —teardownFcn
runs a single time after all the tests in the class.
To restore the environment, the method enforces a last-in, first-out (LIFO) policy so
that teardown actions are performed in the reverse order of their corresponding setup
actions. Use addTeardown
to achieve test content that is exception
safe.
addTeardown(
also specifies the input arguments with which testCase
,teardownFcn
,input1,...,inputN
)teardownFcn
is invoked
for fixture teardown.
Input Arguments
Examples
More About
Version History
Introduced in R2013a