addTeardown
类: matlab.unittest.TestCase
命名空间: matlab.unittest
向测试用例动态添加拆解代码
说明
addTeardown( 可向测试用例注册拆解代码 testCase,teardownFcn)teardownFcn。要在测试运行时动态运行拆解代码,请在 Test 方法、TestMethodSetup 方法或 TestClassSetup 方法中使用 addTeardown。拆解操作的时间和频率取决于调用方法的作用域:
Test方法 -teardownFcn在当前测试后运行。TestMethodSetup方法 -teardownFcn在测试类中的每个测试后运行。TestClassSetup方法 -teardownFcn在类中的所有测试后运行一次。
为了还原环境,该方法会强制应用后进先出 (LIFO) 策略,使拆解操作以与其对应的设置操作相反的顺序执行。使用 addTeardown 获得满足异常安全条件的测试内容。
addTeardown( 还可指定调用 testCase,teardownFcn,input1,...,inputN)teardownFcn 来拆解脚手架时使用的输入参量。
输入参数
示例
详细信息
版本历史记录
在 R2013a 中推出