[b4b313]: / matlab_xunit_3.1 / matlab_xunit / tests / TestCaseTest.m

Download this file

57 lines (47 with data), 2.1 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
54
55
56
57
%TestCaseTest Unit tests for the TestCase class
% Steven L. Eddins
% Copyright The MathWorks 2008
classdef TestCaseTest < TestCaseInDir
methods
function self = TestCaseTest(name)
self = self@TestCaseInDir(name, ...
fullfile(fileparts(which(mfilename)), 'helper_classes'));
end
function testConstructor(self)
% Exercise the constructor. Verify that the Name and Location
% properties are set correctly.
tc = TwoPassingTests('testMethod1');
assertEqual(tc.Name, 'testMethod1');
assertEqual(tc.Location, which('TwoPassingTests'));
end
function testPassingTests(self)
% Verify that the expected observer notifications are received in
% the proper order.
logger = TestRunLogger();
TestSuite('TwoPassingTests').run(logger);
assertTrue(isequal(logger.Log, ...
{'TestRunStarted', 'TestComponentStarted', ...
'TestComponentStarted', 'TestComponentFinished', ...
'TestComponentStarted', 'TestComponentFinished', ...
'TestComponentFinished', 'TestRunFinished'}));
end
function testFixtureCalls(self)
% Verify that fixture calls are made in the proper order.
tc = LoggingTestCase('testMethod');
tc.run(TestRunLogger());
assertTrue(isequal(tc.log, {'setUp', 'testMethod', 'tearDown'}));
end
function testTestFailure(self)
% Verify that a test failure is recorded.
logger = TestRunLogger();
TestSuite('FailingTestCase').run(logger);
assertTrue(isequal(logger.NumFailures, 1));
end
function testTestError(self)
% Verify that a test error is recorded.
logger = TestRunLogger();
TestSuite('BadFixture').run(logger);
assertTrue(isequal(logger.NumErrors, 1));
end
end
end