Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

addTeardown

Class: matlab.unittest.TestCase
Package: matlab.unittest

Dynamically add teardown routine

Syntax

addTeardown(testCase,tearDownFcn)
addTeardown(testCase,tearDownFcn,arg1,...,argN)

Description

addTeardown(testCase,tearDownFcn) adds the tearDownFcn function handle that defines fixture teardown code to the testCase instance. The teardown code is executed in the reverse order to which it is added. This is known as LIFO (or Last-In-First-Out).

addTeardown(testCase,tearDownFcn,arg1,...,argN)

Input Arguments

testCase

matlab.unittest.TestCase instance

tearDownFcn

Function, specified as a function handle, that defines the fixture teardown code

arg1,...,argN

Input arguments, 1 through N (if any), required by tearDownFcn, specified by any type. The argument type is specified by the function argument list.

Examples

expand all

Call addTeardown in a TestMethodSetup Method

classdef SomeTest < matlab.unittest.TestCase
 
    methods(TestMethodSetup)
        function createFixture(testCase)
            p = path;
            testCase.addTeardown(@path, p);
            addpath(fullfile(pwd,'testHelpers'));
        end
    end
end
Was this topic helpful?