minitest-reporters 1.3.0 → 1.3.1.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +27 -27
- data/.ruby-gemset +1 -1
- data/.travis.yml +10 -10
- data/.yardopts +5 -5
- data/CHANGELOG.md +58 -54
- data/Gemfile +2 -2
- data/LICENSE +19 -19
- data/README.md +134 -134
- data/Rakefile +60 -60
- data/lib/minitest/extensible_backtrace_filter.rb +67 -67
- data/lib/minitest/minitest_reporter_plugin.rb +75 -75
- data/lib/minitest/old_activesupport_fix.rb +24 -24
- data/lib/minitest/relative_position.rb +26 -26
- data/lib/minitest/reporters.rb +91 -91
- data/lib/minitest/reporters/ansi.rb +31 -31
- data/lib/minitest/reporters/base_reporter.rb +119 -117
- data/lib/minitest/reporters/default_reporter.rb +228 -228
- data/lib/minitest/reporters/html_reporter.rb +221 -221
- data/lib/minitest/reporters/junit_reporter.rb +158 -158
- data/lib/minitest/reporters/mean_time_reporter.rb +392 -392
- data/lib/minitest/reporters/progress_reporter.rb +96 -96
- data/lib/minitest/reporters/ruby_mate_reporter.rb +54 -54
- data/lib/minitest/reporters/rubymine_reporter.rb +117 -117
- data/lib/minitest/reporters/spec_reporter.rb +61 -61
- data/lib/minitest/reporters/version.rb +5 -5
- data/lib/minitest/templates/index.html.erb +82 -82
- data/minitest-reporters.gemspec +31 -31
- data/test/fixtures/junit_filename_bug_example_test.rb +21 -21
- data/test/fixtures/mean_time_test.rb +8 -8
- data/test/fixtures/progress_detailed_skip_test.rb +8 -8
- data/test/fixtures/progress_test.rb +8 -8
- data/test/fixtures/sample_test.rb +15 -15
- data/test/fixtures/spec_test.rb +13 -13
- data/test/gallery/bad_test.rb +25 -25
- data/test/gallery/good_test.rb +14 -14
- data/test/integration/reporters/junit_reporter_test.rb +12 -12
- data/test/integration/reporters/mean_time_reporter_test.rb +7 -7
- data/test/integration/reporters/progress_reporter_test.rb +34 -34
- data/test/test_helper.rb +22 -22
- data/test/unit/minitest/extensible_backtrace_filter_test.rb +42 -42
- data/test/unit/minitest/mean_time_reporter_unit_test.rb +152 -152
- data/test/unit/minitest/minitest_reporter_plugin_test.rb +14 -14
- data/test/unit/minitest/reporters_test.rb +65 -65
- data/test/unit/minitest/spec_reporter_test.rb +41 -41
- metadata +4 -4
@@ -1,228 +1,228 @@
|
|
1
|
-
module Minitest
|
2
|
-
module Reporters
|
3
|
-
# A reporter identical to the standard Minitest reporter except with more
|
4
|
-
# colors.
|
5
|
-
#
|
6
|
-
# Based upon Ryan Davis of Seattle.rb's Minitest (MIT License).
|
7
|
-
#
|
8
|
-
# @see https://github.com/seattlerb/minitest Minitest
|
9
|
-
|
10
|
-
class DefaultReporter < BaseReporter
|
11
|
-
include ANSI::Code
|
12
|
-
include RelativePosition
|
13
|
-
|
14
|
-
def initialize(options = {})
|
15
|
-
super
|
16
|
-
@detailed_skip = options.fetch(:detailed_skip, true)
|
17
|
-
@slow_count = options.fetch(:slow_count, 0)
|
18
|
-
@slow_suite_count = options.fetch(:slow_suite_count, 0)
|
19
|
-
@suite_times = []
|
20
|
-
@suite_start_times = {}
|
21
|
-
@fast_fail = options.fetch(:fast_fail, false)
|
22
|
-
@options = options
|
23
|
-
end
|
24
|
-
|
25
|
-
def start
|
26
|
-
super
|
27
|
-
on_start
|
28
|
-
end
|
29
|
-
|
30
|
-
def on_start
|
31
|
-
puts
|
32
|
-
puts("# Running tests with run options %s:" % options[:args])
|
33
|
-
puts
|
34
|
-
end
|
35
|
-
|
36
|
-
def before_test(test)
|
37
|
-
super
|
38
|
-
print "\n#{test.class}##{test.name} " if options[:verbose]
|
39
|
-
end
|
40
|
-
|
41
|
-
def before_suite(suite)
|
42
|
-
@suite_start_times[suite] = Minitest::Reporters.clock_time
|
43
|
-
super
|
44
|
-
end
|
45
|
-
|
46
|
-
def after_suite(suite)
|
47
|
-
super
|
48
|
-
duration = suite_duration(suite)
|
49
|
-
@suite_times << [suite.name, duration]
|
50
|
-
end
|
51
|
-
|
52
|
-
def record(test)
|
53
|
-
super
|
54
|
-
|
55
|
-
on_record(test)
|
56
|
-
end
|
57
|
-
|
58
|
-
def on_record(test)
|
59
|
-
print "#{"%.2f" % test.time} = " if options[:verbose]
|
60
|
-
|
61
|
-
# Print the pass/skip/fail mark
|
62
|
-
print(if test.passed?
|
63
|
-
record_pass(test)
|
64
|
-
elsif test.skipped?
|
65
|
-
record_skip(test)
|
66
|
-
elsif test.failure
|
67
|
-
record_failure(test)
|
68
|
-
end)
|
69
|
-
|
70
|
-
# Print fast_fail information
|
71
|
-
if @fast_fail && (test.skipped? || test.failure)
|
72
|
-
print_failure(test)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def record_pass(record)
|
77
|
-
green(record.result_code)
|
78
|
-
end
|
79
|
-
|
80
|
-
def record_skip(record)
|
81
|
-
yellow(record.result_code)
|
82
|
-
end
|
83
|
-
|
84
|
-
def record_failure(record)
|
85
|
-
red(record.result_code)
|
86
|
-
end
|
87
|
-
|
88
|
-
def report
|
89
|
-
super
|
90
|
-
on_report
|
91
|
-
end
|
92
|
-
|
93
|
-
def on_report
|
94
|
-
status_line = "Finished tests in %.6fs, %.4f tests/s, %.4f assertions/s." %
|
95
|
-
[total_time, count / total_time, assertions / total_time]
|
96
|
-
|
97
|
-
puts
|
98
|
-
puts
|
99
|
-
puts colored_for(suite_result, status_line)
|
100
|
-
puts
|
101
|
-
|
102
|
-
unless @fast_fail
|
103
|
-
tests.reject(&:passed?).each do |test|
|
104
|
-
print_failure(test)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
if @slow_count > 0
|
109
|
-
slow_tests = tests.sort_by(&:time).reverse.take(@slow_count)
|
110
|
-
|
111
|
-
puts
|
112
|
-
puts "Slowest tests:"
|
113
|
-
puts
|
114
|
-
|
115
|
-
slow_tests.each do |test|
|
116
|
-
puts "%.6fs %s" % [test.time, "#{test.name}##{test_class(test)}"]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
if @slow_suite_count > 0
|
121
|
-
slow_suites = @suite_times.sort_by { |x| x[1] }.reverse.take(@slow_suite_count)
|
122
|
-
|
123
|
-
puts
|
124
|
-
puts "Slowest test classes:"
|
125
|
-
puts
|
126
|
-
|
127
|
-
slow_suites.each do |slow_suite|
|
128
|
-
puts "%.6fs %s" % [slow_suite[1],
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
puts
|
133
|
-
print colored_for(suite_result, result_line)
|
134
|
-
puts
|
135
|
-
end
|
136
|
-
|
137
|
-
alias to_s report
|
138
|
-
|
139
|
-
def print_failure(test)
|
140
|
-
message = message_for(test)
|
141
|
-
unless message.nil? || message.strip == ''
|
142
|
-
puts
|
143
|
-
puts colored_for(result(test), message)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
private
|
148
|
-
|
149
|
-
def color?
|
150
|
-
return @color if defined?(@color)
|
151
|
-
@color = @options.fetch(:color) do
|
152
|
-
io.tty? && (
|
153
|
-
ENV["TERM"] =~ /^screen|color/ ||
|
154
|
-
ENV["EMACS"] == "t"
|
155
|
-
)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def green(string)
|
160
|
-
color? ? ANSI::Code.green(string) : string
|
161
|
-
end
|
162
|
-
|
163
|
-
def yellow(string)
|
164
|
-
color? ? ANSI::Code.yellow(string) : string
|
165
|
-
end
|
166
|
-
|
167
|
-
def red(string)
|
168
|
-
color? ? ANSI::Code.red(string) : string
|
169
|
-
end
|
170
|
-
|
171
|
-
def colored_for(result, string)
|
172
|
-
case result
|
173
|
-
when :fail, :error; red(string)
|
174
|
-
when :skip; yellow(string)
|
175
|
-
else green(string)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
def suite_result
|
180
|
-
case
|
181
|
-
when failures > 0; :fail
|
182
|
-
when errors > 0; :error
|
183
|
-
when skips > 0; :skip
|
184
|
-
else :pass
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def location(exception)
|
189
|
-
last_before_assertion = ''
|
190
|
-
|
191
|
-
exception.backtrace.reverse_each do |s|
|
192
|
-
break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
|
193
|
-
last_before_assertion = s
|
194
|
-
end
|
195
|
-
|
196
|
-
last_before_assertion.sub(/:in .*$/, '')
|
197
|
-
end
|
198
|
-
|
199
|
-
def message_for(test)
|
200
|
-
e = test.failure
|
201
|
-
|
202
|
-
if test.skipped?
|
203
|
-
if @detailed_skip
|
204
|
-
"Skipped:\n#{test_class(test)}##{test.name} [#{location(e)}]:\n#{e.message}"
|
205
|
-
end
|
206
|
-
elsif test.error?
|
207
|
-
"Error:\n#{test_class(test)}##{test.name}:\n#{e.message}"
|
208
|
-
else
|
209
|
-
"Failure:\n#{test_class(test)}##{test.name} [#{test.failure.location}]\n#{e.class}: #{e.message}"
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def result_line
|
214
|
-
'%d tests, %d assertions, %d failures, %d errors, %d skips' %
|
215
|
-
[count, assertions, failures, errors, skips]
|
216
|
-
end
|
217
|
-
|
218
|
-
def suite_duration(suite)
|
219
|
-
start_time = @suite_start_times.delete(suite)
|
220
|
-
if start_time.nil?
|
221
|
-
0
|
222
|
-
else
|
223
|
-
Minitest::Reporters.clock_time - start_time
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
1
|
+
module Minitest
|
2
|
+
module Reporters
|
3
|
+
# A reporter identical to the standard Minitest reporter except with more
|
4
|
+
# colors.
|
5
|
+
#
|
6
|
+
# Based upon Ryan Davis of Seattle.rb's Minitest (MIT License).
|
7
|
+
#
|
8
|
+
# @see https://github.com/seattlerb/minitest Minitest
|
9
|
+
|
10
|
+
class DefaultReporter < BaseReporter
|
11
|
+
include ANSI::Code
|
12
|
+
include RelativePosition
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
super
|
16
|
+
@detailed_skip = options.fetch(:detailed_skip, true)
|
17
|
+
@slow_count = options.fetch(:slow_count, 0)
|
18
|
+
@slow_suite_count = options.fetch(:slow_suite_count, 0)
|
19
|
+
@suite_times = []
|
20
|
+
@suite_start_times = {}
|
21
|
+
@fast_fail = options.fetch(:fast_fail, false)
|
22
|
+
@options = options
|
23
|
+
end
|
24
|
+
|
25
|
+
def start
|
26
|
+
super
|
27
|
+
on_start
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_start
|
31
|
+
puts
|
32
|
+
puts("# Running tests with run options %s:" % options[:args])
|
33
|
+
puts
|
34
|
+
end
|
35
|
+
|
36
|
+
def before_test(test)
|
37
|
+
super
|
38
|
+
print "\n#{test.class}##{test.name} " if options[:verbose]
|
39
|
+
end
|
40
|
+
|
41
|
+
def before_suite(suite)
|
42
|
+
@suite_start_times[suite] = Minitest::Reporters.clock_time
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def after_suite(suite)
|
47
|
+
super
|
48
|
+
duration = suite_duration(suite)
|
49
|
+
@suite_times << [suite.name, duration]
|
50
|
+
end
|
51
|
+
|
52
|
+
def record(test)
|
53
|
+
super
|
54
|
+
|
55
|
+
on_record(test)
|
56
|
+
end
|
57
|
+
|
58
|
+
def on_record(test)
|
59
|
+
print "#{"%.2f" % test.time} = " if options[:verbose]
|
60
|
+
|
61
|
+
# Print the pass/skip/fail mark
|
62
|
+
print(if test.passed?
|
63
|
+
record_pass(test)
|
64
|
+
elsif test.skipped?
|
65
|
+
record_skip(test)
|
66
|
+
elsif test.failure
|
67
|
+
record_failure(test)
|
68
|
+
end)
|
69
|
+
|
70
|
+
# Print fast_fail information
|
71
|
+
if @fast_fail && (test.skipped? || test.failure)
|
72
|
+
print_failure(test)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def record_pass(record)
|
77
|
+
green(record.result_code)
|
78
|
+
end
|
79
|
+
|
80
|
+
def record_skip(record)
|
81
|
+
yellow(record.result_code)
|
82
|
+
end
|
83
|
+
|
84
|
+
def record_failure(record)
|
85
|
+
red(record.result_code)
|
86
|
+
end
|
87
|
+
|
88
|
+
def report
|
89
|
+
super
|
90
|
+
on_report
|
91
|
+
end
|
92
|
+
|
93
|
+
def on_report
|
94
|
+
status_line = "Finished tests in %.6fs, %.4f tests/s, %.4f assertions/s." %
|
95
|
+
[total_time, count / total_time, assertions / total_time]
|
96
|
+
|
97
|
+
puts
|
98
|
+
puts
|
99
|
+
puts colored_for(suite_result, status_line)
|
100
|
+
puts
|
101
|
+
|
102
|
+
unless @fast_fail
|
103
|
+
tests.reject(&:passed?).each do |test|
|
104
|
+
print_failure(test)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
if @slow_count > 0
|
109
|
+
slow_tests = tests.sort_by(&:time).reverse.take(@slow_count)
|
110
|
+
|
111
|
+
puts
|
112
|
+
puts "Slowest tests:"
|
113
|
+
puts
|
114
|
+
|
115
|
+
slow_tests.each do |test|
|
116
|
+
puts "%.6fs %s" % [test.time, "#{test.name}##{test_class(test)}"]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
if @slow_suite_count > 0
|
121
|
+
slow_suites = @suite_times.sort_by { |x| x[1] }.reverse.take(@slow_suite_count)
|
122
|
+
|
123
|
+
puts
|
124
|
+
puts "Slowest test classes:"
|
125
|
+
puts
|
126
|
+
|
127
|
+
slow_suites.each do |slow_suite|
|
128
|
+
puts "%.6fs %s" % [slow_suite[1], slow_suite[0]]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
puts
|
133
|
+
print colored_for(suite_result, result_line)
|
134
|
+
puts
|
135
|
+
end
|
136
|
+
|
137
|
+
alias to_s report
|
138
|
+
|
139
|
+
def print_failure(test)
|
140
|
+
message = message_for(test)
|
141
|
+
unless message.nil? || message.strip == ''
|
142
|
+
puts
|
143
|
+
puts colored_for(result(test), message)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def color?
|
150
|
+
return @color if defined?(@color)
|
151
|
+
@color = @options.fetch(:color) do
|
152
|
+
io.tty? && (
|
153
|
+
ENV["TERM"] =~ /^screen|color/ ||
|
154
|
+
ENV["EMACS"] == "t"
|
155
|
+
)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def green(string)
|
160
|
+
color? ? ANSI::Code.green(string) : string
|
161
|
+
end
|
162
|
+
|
163
|
+
def yellow(string)
|
164
|
+
color? ? ANSI::Code.yellow(string) : string
|
165
|
+
end
|
166
|
+
|
167
|
+
def red(string)
|
168
|
+
color? ? ANSI::Code.red(string) : string
|
169
|
+
end
|
170
|
+
|
171
|
+
def colored_for(result, string)
|
172
|
+
case result
|
173
|
+
when :fail, :error; red(string)
|
174
|
+
when :skip; yellow(string)
|
175
|
+
else green(string)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def suite_result
|
180
|
+
case
|
181
|
+
when failures > 0; :fail
|
182
|
+
when errors > 0; :error
|
183
|
+
when skips > 0; :skip
|
184
|
+
else :pass
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def location(exception)
|
189
|
+
last_before_assertion = ''
|
190
|
+
|
191
|
+
exception.backtrace.reverse_each do |s|
|
192
|
+
break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
|
193
|
+
last_before_assertion = s
|
194
|
+
end
|
195
|
+
|
196
|
+
last_before_assertion.sub(/:in .*$/, '')
|
197
|
+
end
|
198
|
+
|
199
|
+
def message_for(test)
|
200
|
+
e = test.failure
|
201
|
+
|
202
|
+
if test.skipped?
|
203
|
+
if @detailed_skip
|
204
|
+
"Skipped:\n#{test_class(test)}##{test.name} [#{location(e)}]:\n#{e.message}"
|
205
|
+
end
|
206
|
+
elsif test.error?
|
207
|
+
"Error:\n#{test_class(test)}##{test.name}:\n#{e.message}"
|
208
|
+
else
|
209
|
+
"Failure:\n#{test_class(test)}##{test.name} [#{test.failure.location}]\n#{e.class}: #{e.message}"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def result_line
|
214
|
+
'%d tests, %d assertions, %d failures, %d errors, %d skips' %
|
215
|
+
[count, assertions, failures, errors, skips]
|
216
|
+
end
|
217
|
+
|
218
|
+
def suite_duration(suite)
|
219
|
+
start_time = @suite_start_times.delete(suite)
|
220
|
+
if start_time.nil?
|
221
|
+
0
|
222
|
+
else
|
223
|
+
Minitest::Reporters.clock_time - start_time
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|