Class: TapOut::Reporters::Breakdown
Overview
The Breakdown report format give a tally for each test case.
Constant Summary
Constants inherited
from Abstract
Abstract::INTERNALS
Instance Method Summary
collapse
Methods inherited from Abstract
#<<, #clean_backtrace, #code_snippet, #err, #fail, #handle, inherited, #note, #omit, #parse_source_location, #pass, #skip, #source, #tally
Constructor Details
Returns a new instance of Breakdown.
10
11
12
13
14
|
# File 'lib/tapout/reporters/breakdown.rb', line 10
def initialize
super
@case = {}
@case_entries = []
end
|
Instance Method Details
#finish_case(entry) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/tapout/reporters/breakdown.rb', line 31
def finish_case(entry)
label = entry['label'][0,19]
groups = @case_entries.group_by{ |e| e['status'] }
total = @case_entries.size
sums = %w{pass fail error pending}.map{ |n| groups[n] ? groups[n].size : 0 }
result = sums[1] + sums[2] > 0 ? "FAIL".ansi(:red) : "PASS".ansi(:green)
puts "%-20s %8s %8s %8s %8s %8s [%s]" % ([label, total] + sums + [result])
end
|
#finish_suite(entry) ⇒ Object
44
45
46
47
|
# File 'lib/tapout/reporters/breakdown.rb', line 44
def finish_suite(entry)
post_report(entry)
end
|
#post_report(entry) ⇒ Object
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
114
|
# File 'lib/tapout/reporters/breakdown.rb', line 50
def post_report(entry)
sums = %w{pass fail error pending}.map{ |n| entry['tally'][n] || 0 }
puts ("-" * 80)
tally_line = "%-20s " % "TOTAL"
tally_line << "%8s %8s %8s %8s %8s" % [entry['count'], *sums]
puts(tally_line + "\n")
=begin
tally = test_tally(entry)
width = suite.collect{ |tr| tr.name.size }.max
headers = [ 'TESTCASE ', ' TESTS ', 'ASSERTIONS', ' FAILURES ', ' ERRORS ' ]
io.puts "\n%-#{width}s %10s %10s %10s %10s\n" % headers
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
#puts("\n%i tests, %i assertions, %i failures, %i errors\n\n" % tally)
tally_line = "-----\n"
tally_line << "%-#{width}s " % "TOTAL"
tally_line << "%10s %10s %10s %10s" % tally
io.puts(tally_line + "\n")
=end
bad = @failed + @raised
unless bad.empty? puts
bad.each do |e|
x = e['exception']
message = x['message'].strip
message = message.ansi(:red)
puts(message)
puts "#{x['file']}:#{x['line']}"
puts
puts code_snippet(x)
end
puts
end
puts tally(entry)
end
|
#start_case(entry) ⇒ Object
21
22
23
24
|
# File 'lib/tapout/reporters/breakdown.rb', line 21
def start_case(entry)
@case = entry
@case_entries = []
end
|
#start_suite(entry) ⇒ Object
16
17
18
19
|
# File 'lib/tapout/reporters/breakdown.rb', line 16
def start_suite(entry)
= [ 'TESTCASE', 'TESTS', 'PASS', 'FAIL', 'ERR', 'SKIP' ]
puts "\n%-20s %8s %8s %8s %8s %8s\n" %
end
|
#test(entry) ⇒ Object
26
27
28
|
# File 'lib/tapout/reporters/breakdown.rb', line 26
def test(entry)
@case_entries << entry
end
|