[b4b313]: / matlab_xunit_3.1 / matlab_xunit / xunit / TestCaseWithAddPath.m

Download this file

54 lines (47 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%TestCaseInDir Test case requiring temporary path modification
% The TestCaseInDir class defines a test case that has to be run by first
% adding a specific directory to the path.
%
% The setUp method adds the directory to the path, and the tearDown method
% restores the original path.
%
% TestCaseWithAddPath is used by MATLAB xUnit's own test suite in order to test
% itself.
%
% TestCaseWithAddPath methods:
% TestCaseWithAddPath - Constructor
% setUp - Add test directory to MATLAB path
% tearDown - Restore original MATLAB path
%
% See also TestCase, TestCaseInDir
% Steven L. Eddins
% Copyright 2008-2009 The MathWorks, Inc.
classdef TestCaseWithAddPath < TestCase
properties (SetAccess = private, GetAccess = private)
%TestDirectory - Directory to be added to the path
TestDirectory
%OriginalPath - Path prior to adding the test directory
OriginalPath
end
methods
function self = TestCaseWithAddPath(methodName, testDirectory)
%TestCaseInDir Constructor
% TestCaseInDir(testName, testDirectory) constructs a test case
% using the specified name and located in the specified directory.
self = self@TestCase(methodName);
self.TestDirectory = testDirectory;
end
function setUp(self)
%setUp Add test directory to MATLAB path.
% test_case.setUp() saves the current path in the OriginalPath
% property and then adds the TestDirectory to the MATLAB path.
self.OriginalPath = path;
addpath(self.TestDirectory);
end
function tearDown(self)
%tearDown Restore original MATLAB path
% test_case.tearDown() restores the saved MATLAB path.
path(self.OriginalPath);
end
end
end