Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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) provides input arguments to the tearDownFcn.

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

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?