from
mlunit_2008a
by Christopher
A MATLAB unit test framework supporting new classdef files (r2008a)
|
| TestCaseResult |
classdef TestCaseResult < TestResult
% TESTCASERESULT Records the results of test cases and methods.
%
% This class is part of the mlunit_2008a testing framework.
properties
end
methods
function self = TestCaseResult(varargin)
self = self@TestResult(varargin{:});
end
function initialize(self)
if isempty(self.test)
error('Cannot initialize test result without test case!');
end
self.test.clearStop();
names = self.test.getTestNames();
for i = 1:length(names)
self.children.(names{i}) = [];
end
self.testCount = length(names);
self.failureCount = 0;
self.successCount = 0;
end
function clearResults(self)
self.failureCount = 0;
self.successCount = 0;
end
% I probably should have implemented a TestMethodResult class, but
% instead I have this simple and somewhat lame storage method.
% Essentially, on failure I store a struct with the error message
% and stack, whereas on success I just store the string 'S'.
function recordFailure(self, name, msg, stack)
self.children.(name).message = msg;
self.children.(name).stack = stack;
self.incrementFailureCount();
end
function recordSuccess(self, name)
self.children.(name) = 'S';
self.incrementSuccessCount();
end
function tf = isSuite(self)
tf = false;
end
function runTests(self)
self.test.runTests(self);
end
function stopTests(self)
self.test.stopTests();
end
end
end
|
|
Contact us at files@mathworks.com