Class: Turn::ProgressReporter
Constant Summary
Constants included
from Colorize
Colorize::COLORLESS_TERMINALS
Instance Attribute Summary
Attributes inherited from Reporter
#io
Instance Method Summary
collapse
Methods inherited from Reporter
#finish_test, #pass, #start_test
Methods included from Colorize
blue, bold, color_supported?, colorize?, #colorize?, error, fail, green, included, magenta, pass, red, skip
Constructor Details
Returns a new instance of ProgressReporter.
9
10
11
12
13
14
|
# File 'lib/turn/reporters/progress_reporter.rb', line 9
def initialize(io, opts={})
super(io, opts)
@fails = Hash.new{|h,k|h[k]=[]}
@errors = Hash.new{|h,k|h[k]=[]}
@skips = Hash.new{|h,k|h[k]=[]}
end
|
Instance Method Details
#error(exception, message = nil) ⇒ Object
35
36
37
|
# File 'lib/turn/reporters/progress_reporter.rb', line 35
def error(exception, message=nil)
@errors[@_current_case] << exception
end
|
#fail(assertion, message = nil) ⇒ Object
def pass(message=nil) end
31
32
33
|
# File 'lib/turn/reporters/progress_reporter.rb', line 31
def fail(assertion, message=nil)
@fails[@_current_case] << assertion
end
|
#finish_case(kase) ⇒ Object
43
44
45
|
# File 'lib/turn/reporters/progress_reporter.rb', line 43
def finish_case(kase)
@pbar.inc
end
|
#finish_suite(suite) ⇒ Object
47
48
49
50
|
# File 'lib/turn/reporters/progress_reporter.rb', line 47
def finish_suite(suite)
@pbar.finish
post_report(suite)
end
|
#post_report(suite) ⇒ Object
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
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/turn/reporters/progress_reporter.rb', line 53
def post_report(suite)
tally = test_tally(suite)
width = suite.collect{ |tr| tr.name.to_s.size }.max
= [ 'TESTCASE ', ' TESTS ', 'ASSERTIONS', ' FAILURES ', ' ERRORS ', 'SKIPS ' ]
io.puts "\n\n%-#{width}s %10s %10s %10s %10s %10s\n" %
io.puts ("-" * (width + 60))
files = nil
suite.each do |testrun|
if testrun.files != [testrun.name] && testrun.files != files
label = testrun.files.join(' ')
label = Colorize.magenta(label)
io.puts(label + "\n")
files = testrun.files
end
io.puts paint_line(testrun, width)
end
tally_line = ("-" * (width + 60))
tally_line << "\n%-#{width}s " % "TOTAL"
tally_line << "%10s %10s %10s %10s %10s" % tally
io.puts(tally_line + "\n\n\n")
io.puts "-- Failures --\n\n" unless @fails.empty?
@fails.each do |tc, cc|
cc.each do |e|
message = e.message.tabto(0).strip
message = Colorize.red(message)
message += "\n" + clean_backtrace(e.backtrace).join("\n")
io.puts(message+"\n\n")
end
io.puts
end
io.puts "-- Errors --\n\n" unless @errors.empty?
@errors.each do |tc, cc|
cc.each do |e|
message = e.message.tabto(0).strip
message = Colorize.red(message)
message += "\n" + clean_backtrace(e.backtrace).join("\n")
io.puts(message+"\n\n")
end
io.puts
end
end
|
#skip(exception, message = nil) ⇒ Object
39
40
41
|
# File 'lib/turn/reporters/progress_reporter.rb', line 39
def skip(exception, message=nil)
@skips[@_current_case] << exception
end
|
#start_case(testcase) ⇒ Object
21
22
23
|
# File 'lib/turn/reporters/progress_reporter.rb', line 21
def start_case(testcase)
@_current_case = testcase
end
|
#start_suite(suite) ⇒ Object
16
17
18
19
|
# File 'lib/turn/reporters/progress_reporter.rb', line 16
def start_suite(suite)
@pbar = ::ANSI::Progressbar.new('Testing', suite.size)
@pbar.inc
end
|