Class: Test::Reporters::Progress
Overview
Progess reporter gives test counter, precentage and times.
Instance Attribute Summary
Attributes inherited from Abstract
#runner
Instance Method Summary
collapse
Methods inherited from Abstract
#clean_backtrace, #code, #end_test, #file, #file_and_line, #file_and_line_array, inherited, #initialize, #line, #record, registry, #skip_case, #skip_test, #subtotal, #tally, #timestamp, #total, #total_count
Instance Method Details
#begin_case(tc) ⇒ Object
28
29
30
31
32
|
# File 'lib/test/reporters/progress.rb', line 28
def begin_case(tc)
(' ', tc.to_s)
@tab += 2
end
|
#begin_suite(suite) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/test/reporters/progress.rb', line 12
def begin_suite(suite)
@tab = 0
@total_count = total_count(suite)
@start_time = Time.now
@test_cache = {}
@count = 0
max = @total_count.to_s.size
@layout_head = " %3u%% %#{max}s %#{max}s %8s %11s %1s %s"
@layout = " %3u%% %#{max}u/%#{max}u %8s %11s %1s %s"
timer_reset
end
|
#begin_test(test) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/test/reporters/progress.rb', line 35
def begin_test(test)
if test.respond_to?(:topic) && test.topic
topic = test.topic.to_s.rstrip
@test_cache[topic] ||= (
(' ', topic) unless topic.empty?
true
)
end
timer_reset
end
|
#end_case(tcase) ⇒ Object
72
73
74
|
# File 'lib/test/reporters/progress.rb', line 72
def end_case(tcase)
@tab -= 2
end
|
#end_suite(suite) ⇒ Object
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/test/reporters/progress.rb', line 77
def end_suite(suite)
puts
if runner.verbose?
unless record[:omit].empty?
puts "OMISSIONS:\n\n"
record[:omit].reverse_each do |test, exception|
s = []
s << "#{test}".ansi(:bold)
s << "#{file_and_line(exception)}"
puts s.join("\n").tabto(4)
puts code(exception).to_s.tabto(7)
puts
end
end
end
unless record[:todo].empty?
puts "PENDING:\n\n"
record[:todo].reverse_each do |test, exception|
s = []
s << "#{test}".ansi(:bold)
s << "#{file_and_line(exception)}"
puts s.join("\n").tabto(4)
puts code(exception).to_s.tabto(7)
puts
end
end
unless record[:fail].empty?
puts "FAILURES:\n\n"
record[:fail].reverse_each do |test, exception|
s = []
s << "#{test}".ansi(:bold)
s << "#{exception}".ansi(:red)
s << "#{file_and_line(exception)}"
puts s.join("\n").tabto(4)
puts code(exception).to_s.tabto(7)
puts
end
end
unless record[:error].empty?
puts "ERRORS:\n\n"
record[:error].reverse_each do |test, exception|
trace = clean_backtrace(exception)[1..-1].map{ |bt| bt.sub(Dir.pwd+'/', '') }
s = []
s << "#{test}".ansi(:bold)
s << "#{exception.class}".ansi(:red)
s << "#{exception}".ansi(:red)
s << "#{file_and_line(exception)}"
puts s.join("\n").tabto(4)
puts code(exception).to_s.tabto(7)
puts trace.join("\n").tabto(4) unless trace.empty?
puts
end
end
puts
puts timestamp
puts
puts tally
end
|
#error(test, exception) ⇒ Object
57
58
59
|
# File 'lib/test/reporters/progress.rb', line 57
def error(test, exception)
show_line("E", test, :red)
end
|
#fail(test, exception) ⇒ Object
52
53
54
|
# File 'lib/test/reporters/progress.rb', line 52
def fail(test, exception)
show_line("F", test, :red)
end
|
#omit(test, exception) ⇒ Object
67
68
69
|
# File 'lib/test/reporters/progress.rb', line 67
def omit(test, exception)
show_line("O", test, :cyan)
end
|
#pass(test) ⇒ Object
47
48
49
|
# File 'lib/test/reporters/progress.rb', line 47
def pass(test)
show_line(".", test, :green)
end
|
#todo(test, exception) ⇒ Object
62
63
64
|
# File 'lib/test/reporters/progress.rb', line 62
def todo(test, exception)
show_line("P", test, :yellow)
end
|