Understanding how testCase.addTeardown works with @path
Show older comments
classdef GoodFixturesTest < matlab.unittest.TestCase
methods(TestMethodSetup)
function addPath1(testCase)
p = addpath(fullfile(pwd, 'path1'));
testCase.addTeardown(@path, p);
end
function addPath2(testCase)
p = addpath(fullfile(pwd, 'path2'));
testCase.addTeardown(@path, p);
end
end
methods(Test)
function runTest(~)
end
end
end
So, I need to deeply understand how addTeardown works in this line
testCase.addTeardown(@path, p);
to remove the search paths of path1 and path2 and restore the original search paths in view of
testCase.addTeardown(tearDownFcn,arg1)
In other words, what is the meaning of passing all the search paths (including path1 and path2) stored in p to the function handle @path in order to restore the original search paths without the full paths of the newly added subfolders path1 and path2?
Accepted Answer
More Answers (0)
Categories
Find more on Write Unit Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!