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

Download this file

113 lines (86 with data), 3.7 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
classdef VerboseTestRunDisplay < TestRunDisplay
%VerboseTestRunDisplay Print test suite execution results.
% VerboseTestRunDisplay is a subclass of
% TestRunDisplay. It supports the -verbose option of runtests.
%
% Overriddent methods:
% testComponentStarted - Update Command Window display
% testComponentFinished - Update Command Window display
% testRunFinished - Update Command Window display at end of run
%
% See also TestRunDisplay, TestRunLogger, TestRunMonitor, TestSuite
% Steven L. Eddins
% Copyright 2010 The MathWorks, Inc.
properties (SetAccess = private, GetAccess = private)
TicStack = uint64([])
end
methods
function self = VerboseTestRunDisplay(output)
if nargin < 1
output = 1;
end
self = self@TestRunDisplay(output);
end
function testComponentStarted(self, component)
%testComponentStarted Update Command Window display
self.pushTic();
if ~isa(component, 'TestCase')
fprintf(self.FileHandle, '\n');
end
fprintf(self.FileHandle, '%s%s', self.indentationSpaces(), component.Name);
if ~isa(component, 'TestCase')
fprintf(self.FileHandle, '\n');
else
fprintf(self.FileHandle, ' %s ', self.leaderDots(component.Name));
end
end
function testComponentFinished(self, component, did_pass)
%testComponentFinished Update Command Window display
if ~isa(component, 'TestCase')
fprintf(self.FileHandle, '%s%s %s ', self.indentationSpaces(), component.Name, ...
self.leaderDots(component.Name));
end
component_run_time = toc(self.popTic());
if did_pass
fprintf(self.FileHandle, 'passed in %12.6f seconds\n', component_run_time);
else
fprintf(self.FileHandle, 'FAILED in %12.6f seconds\n', component_run_time);
end
if ~isa(component, 'TestCase')
fprintf(self.FileHandle, '\n');
end
if isempty(self.TicStack)
self.testRunFinished();
end
end
end
methods (Access = protected)
function testRunFinished(self)
%testRunFinished Update Command Window display
% obj.testRunFinished(component) displays information about the test
% run results, including any test failures, to the Command
% Window.
self.displayFaults();
end
end
methods (Access = private)
function pushTic(self)
self.TicStack(end+1) = tic;
end
function t1 = popTic(self)
t1 = self.TicStack(end);
self.TicStack(end) = [];
end
function str = indentationSpaces(self)
str = repmat(' ', 1, self.numIndentationSpaces());
end
function n = numIndentationSpaces(self)
indent_level = numel(self.TicStack) - 1;
n = 3 * indent_level;
end
function str = leaderDots(self, name)
num_dots = max(0, 60 - self.numIndentationSpaces() - numel(name));
str = repmat('.', 1, num_dots);
end
end
end