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
#<<, #backtrace, #backtrace_snippets, #backtrace_snippets_chain, #captured_output, #captured_output?, #captured_stderr, #captured_stderr?, #captured_stdout, #captured_stdout?, #clean_backtrace, #code_snippet, #complete_cases, #config, #count_tally, #duration, #error, #exit_code, #fail, #finalize, #finish_test, #format_snippet_array, #handle, inherited, #note, #omit, #parse_backtrace, #parse_source_location, #pass, #source, #tally, #tally_message, #time_tally, #todo
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
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 33
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 todo omit}.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 %8s [%s]" % ([label, total] + sums + [result])
end
|
#finish_suite(entry) ⇒ Object
46
47
48
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 46
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
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 51
def post_report(entry)
sums = count_tally(entry)
tally_line = "%-20s " % "TOTAL"
tally_line << "%8s %8s %8s %8s %8s %8s" % sums
puts ("-" * 80)
puts(tally_line + "\n")
index = 1
unless @failed.empty?
puts
@failed.each do |test|
printout(test, index, *config.fail)
index += 1
end
puts
end
unless @raised.empty?
puts
@raised.each do |test|
printout(test, index, *config.fail)
index += 1
end
puts
end
time, rate, avg = time_tally(entry)
puts "Finished in %.4fs at %.2f tests/s." % [time, rate, avg]
puts
puts tally_message(entry)
end
|
#printout(test, index, *ansi) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 90
def printout(test, index, *ansi)
x = test['exception']
label = test['label'].to_s
exclass = test['exception']['class']
message = test['exception']['message']
exclass = nil if exclass.to_s.strip.empty?
message = nil if message.to_s.strip.empty?
print "#{index}. "
print label.ansi(*config.highlight)
print " " + exclass.ansi(*ansi) if exclass
puts
puts message.tabto(4) if message
puts backtrace_snippets(test).tabto(4)
puts captured_output(test).tabto(4)
puts
end
|
#start_case(entry) ⇒ Object
23
24
25
26
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 23
def start_case(entry)
@case = entry
@case_entries = []
end
|
#start_suite(entry) ⇒ Object
17
18
19
20
21
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 17
def start_suite(entry)
= [ 'TESTCASE', 'TESTS', 'PASS', 'FAIL', 'ERROR', 'TODO', 'OMIT' ]
puts "\n%-20s %8s %8s %8s %8s %8s %8s\n" %
puts ("-" * 80)
end
|
#start_test(entry) ⇒ Object
28
29
30
|
# File 'lib/tapout/reporters/breakdown_reporter.rb', line 28
def start_test(entry)
@case_entries << entry
end
|