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:
Testmethod —teardownFcnruns after the current test.TestMethodSetupmethod —teardownFcnruns after each test in the test class.TestClassSetupmethod —teardownFcnruns 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