Class: TapOut::Reporters::BreakdownReporter
- Inherits:
-
Abstract
- Object
- Abstract
- TapOut::Reporters::BreakdownReporter
show all
- Defined in:
- lib/tapout/reporters/breakdown_reporter.rb
Overview
The Breakdown report format gives 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, #complete_cases, #error, #exit_code, #fail, #finalize, #finish_test, #handle, inherited, #note, #omit, #parse_source_location, #pass, #skip, #source, #tally, #tally_message
Constructor Details
Returns a new instance of BreakdownReporter.
11
12
13
14
15
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 11
def initialize
super
@case = {}
@case_entries = []
end
|
Instance Method Details
#finish_case(entry) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 32
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
45
46
47
48
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 45
def finish_suite(entry)
post_report(entry)
end
|
#post_report(entry) ⇒ Object
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
115
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 51
def post_report(entry)
sums = %w{pass fail error todo}.map{ |n| entry['counts'][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['class'],x['message']].compact.join(': ').strip
message = message.ansi(:red)
puts(message)
puts "#{x['file']}:#{x['line']}"
puts
puts code_snippet(x)
end
puts
end
puts tally_message(entry)
end
|
#start_case(entry) ⇒ Object
22
23
24
25
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 22
def start_case(entry)
@case = entry
@case_entries = []
end
|
#start_suite(entry) ⇒ Object
17
18
19
20
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 17
def start_suite(entry)
= [ 'TESTCASE', 'TESTS', 'PASS', 'FAIL', 'ERR', 'SKIP' ]
puts "\n%-20s %8s %8s %8s %8s %8s\n" %
end
|
#start_test(entry) ⇒ Object
27
28
29
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 27
def start_test(entry)
@case_entries << entry
end
|