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

Download this file

113 lines (89 with data), 3.8 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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
%TestSuiteTest Unit tests for runtests command-line test runner.
classdef RuntestsTest < TestCaseInDir
methods
function self = RuntestsTest(name)
self = self@TestCaseInDir(name, ...
fullfile(fileparts(which(mfilename)), 'cwd_test'));
end
function test_noInputArgs(self)
[T, did_pass] = evalc('runtests');
% The cwd_test directory contains some test cases that fail,
% so output of runtests should be false.
assertFalse(did_pass);
end
function test_Verbose(self)
[T, did_pass] = evalc('runtests(''-verbose'')');
assertFalse(did_pass);
end
function test_oneInputArg(self)
[T, did_pass] = evalc('runtests(''testFoobar'')');
% cwd_test/testFoobar.m is supposed to pass.
assertTrue(did_pass);
end
function test_verboseThenTestName(self)
[T, did_pass] = evalc('runtests(''-verbose'', ''.'')');
assertFalse(did_pass);
end
function test_testNameThenVerbose(self)
[T, did_pass] = evalc('runtests(''.'', ''-verbose'')');
assertFalse(did_pass);
end
function test_oneInputArgWithFilter_passing(self)
[T, did_pass] = evalc('runtests(''TestCaseSubclass:testA'')');
assertTrue(did_pass);
end
function test_oneInputArgWithFilter_failing(self)
[T, did_pass] = evalc('runtests(''TestCaseSubclass:testB'')');
assertFalse(did_pass);
end
function test_oneDirname(self)
[T, did_pass] = evalc('runtests(''../dir1'')');
assertTrue(did_pass);
[T, did_pass] = evalc('runtests(''../dir2'')');
assertFalse(did_pass);
end
function test_twoDirnames(self)
[T, did_pass] = evalc('runtests(''../dir1'', ''../dir2'')');
assertFalse(did_pass);
end
function test_packageName(self)
[T, did_pass] = evalc('runtests(''xunit.mocktests'')');
assertTrue(did_pass);
end
function test_noTestCasesFound(self)
assertExceptionThrown(@() runtests('no_such_test'), ...
'xunit:runtests:noTestCasesFound');
end
function test_optionStringsIgnored(self)
% Option string at beginning.
[T, did_pass] = evalc('runtests(''-bogus'', ''../dir1'')');
assertTrue(did_pass);
% Option string at end.
[T, did_pass] = evalc('runtests(''../dir2'', ''-bogus'')');
assertFalse(did_pass);
end
function test_logfile(self)
name = tempname;
command = sprintf('runtests(''../dir1'', ''-logfile'', ''%s'')', name);
[T, did_pass] = evalc(command);
assertTrue(did_pass);
assertTrue(exist(name, 'file') ~= 0);
delete(name);
end
function test_logfileWithNoFile(self)
assertExceptionThrown(@() runtests('../dir1', '-logfile'), ...
'xunit:runtests:MissingLogfile');
end
function test_logfileWithNoWritePermission(self)
assertExceptionThrown(@() runtests('../dir1', '-logfile', ...
'C:\dir__does__not__exist\foobar.txt'), ...
'xunit:runtests:FileOpenFailed');
end
function test_namesInCellArray(self)
[T, did_pass] = evalc('runtests({''TestCaseSubclass:testA''})');
assertTrue(did_pass);
[T, did_pass] = evalc('runtests({''TestCaseSubclass:testA'', ''TestCaseSubclass:testB''})');
assertFalse(did_pass);
end
end
end