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

Download this file

37 lines (30 with data), 1.5 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
classdef ThrowsExceptionTest < TestCaseInDir
methods
function self = ThrowsExceptionTest(methodName)
self = self@TestCaseInDir(methodName, ...
fullfile(fileparts(which(mfilename)), 'helper_classes'));
end
function testPassingTest(self)
logger = TestRunLogger();
TestSuite('PassingExceptionTest').run(logger);
assertTrue((logger.NumTestCases == 1) && ...
(logger.NumFailures == 0) && ...
(logger.NumErrors == 0), ...
'Passing exception test should have no failures or errors');
end
function testNoExceptionTest(self)
logger = TestRunLogger();
TestSuite('ExceptionNotThrownTest').run(logger);
assertTrue(strcmp(logger.Faults(1).Exception.identifier, ...
'assertExceptionThrown:noException'), ...
'Fault exception should be throwsException:noException');
end
function testWrongExceptionTest(self)
logger = TestRunLogger();
TestSuite('WrongExceptionThrownTest').run(logger);
assertTrue(strcmp(logger.Faults(1).Exception.identifier, ...
'assertExceptionThrown:wrongException'), ...
'Fault exception should be throwsException:wrongException');
end
end
end