minitest-reporters 0.14.24 → 1.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -15
- data/Rakefile +1 -5
- data/lib/minitest/extensible_backtrace_filter.rb +4 -4
- data/lib/minitest/minitest_reporter_plugin.rb +29 -0
- data/lib/minitest/old_activesupport_fix.rb +1 -1
- data/lib/minitest/relative_position.rb +2 -2
- data/lib/minitest/reporters/base_reporter.rb +88 -0
- data/lib/minitest/reporters/default_reporter.rb +66 -100
- data/lib/minitest/reporters/junit_reporter.rb +42 -43
- data/lib/minitest/reporters/progress_reporter.rb +36 -72
- data/lib/minitest/reporters/ruby_mate_reporter.rb +34 -48
- data/lib/minitest/reporters/rubymine_reporter.rb +41 -69
- data/lib/minitest/reporters/spec_reporter.rb +22 -65
- data/lib/minitest/reporters/version.rb +2 -2
- data/lib/minitest/reporters.rb +19 -46
- data/minitest-reporters.gemspec +4 -5
- data/test/gallery/bad_test.rb +1 -1
- data/test/gallery/good_test.rb +1 -1
- data/test/integration/fixtures/junit_filename_bug_example_test.rb +2 -2
- data/test/integration/reporters/junit_reporter_test.rb +2 -2
- data/test/test_helper.rb +5 -6
- data/test/unit/minitest/extensible_backtrace_filter_test.rb +3 -3
- data/test/unit/minitest/reporters_test.rb +12 -15
- metadata +27 -52
- data/lib/minitest/around_test_hooks.rb +0 -15
- data/lib/minitest/reporter.rb +0 -38
- data/lib/minitest/reporter_runner.rb +0 -109
- data/lib/minitest/reporters/guard_reporter.rb +0 -32
- data/lib/minitest/test_recorder.rb +0 -22
- data/lib/minitest/test_runner.rb +0 -12
- data/test/unit/minitest/reporter_test.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a4b6d764247a5143cb75e59c7f421ffe3a0d6bb
|
4
|
+
data.tar.gz: 1202b2149bafac15280beaa41b16380032952ef1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b070ec5fba6d3dbf4167b4fda5cbb3c2196ae3e8e68a9c90de21b69974e2a2d2ce9653f03137983d46042b2afd5e222565a2e90f7147b4055e907637592712f
|
7
|
+
data.tar.gz: 376e26b5042f5c6ea2b4705fd4788f0cb72bc4cb5315d3ba07b5eb16985016cea9c00ee098c13367efdd18f4d9391b9b5b554011314596c558b0b4ec8cdf2d0f
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# minitest-reporters - create customizable
|
1
|
+
# minitest-reporters - create customizable Minitest output formats [](http://travis-ci.org/axskern/minitest-reporters)
|
2
2
|
|
3
|
-
Death to haphazard monkey-patching! Extend
|
3
|
+
Death to haphazard monkey-patching! Extend Minitest through simple hooks.
|
4
4
|
|
5
5
|
## Installation ##
|
6
6
|
|
@@ -12,45 +12,44 @@ In your `test_helper.rb` file, add the following lines:
|
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
require "minitest/reporters"
|
15
|
-
|
15
|
+
Minitest::Reporters.use!
|
16
16
|
```
|
17
17
|
|
18
|
-
This will swap out the
|
18
|
+
This will swap out the Minitest runner to the custom one used by minitest-reporters and use the correct reporters for Textmate, Rubymine, and the console. If you would like to write your own reporter, just `include Minitest::Reporter` and override the methods you'd like. Take a look at the provided reporters for examples.
|
19
19
|
|
20
20
|
Don't like the default progress bar reporter?
|
21
21
|
|
22
22
|
```ruby
|
23
|
-
|
23
|
+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
24
24
|
```
|
25
25
|
|
26
26
|
Want to use multiple reporters?
|
27
27
|
|
28
28
|
```ruby
|
29
|
-
|
29
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new, Minitest::Reporters::JUnitReporter]
|
30
30
|
```
|
31
31
|
|
32
32
|
The following reporters are provided:
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
MiniTest::Reporters::JUnitReporter # => JUnit test reporter designed for JetBrains TeamCity
|
35
|
+
Minitest::Reporters::DefaultReporter # => Redgreen-capable version of standard Minitest reporter
|
36
|
+
Minitest::Reporters::SpecReporter # => Turn-like output that reads like a spec
|
37
|
+
Minitest::Reporters::ProgressReporter # => Fuubar-like output with a progress bar
|
38
|
+
Minitest::Reporters::RubyMateReporter # => Simple reporter designed for RubyMate
|
39
|
+
Minitest::Reporters::RubyMineReporter # => Reporter designed for RubyMine IDE and TeamCity CI server
|
40
|
+
Minitest::Reporters::JUnitReporter # => JUnit test reporter designed for JetBrains TeamCity
|
42
41
|
```
|
43
42
|
|
44
43
|
Options can be passed to these reporters at construction-time, e.g. to force
|
45
44
|
color output from `DefaultReporter`:
|
46
45
|
|
47
46
|
```ruby
|
48
|
-
|
47
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new(:color => true)]
|
49
48
|
```
|
50
49
|
|
51
50
|
## Caveats ##
|
52
51
|
|
53
|
-
If you are using minitest-reporters with ActiveSupport 3.x, make sure that you require ActiveSupport before invoking `
|
52
|
+
If you are using minitest-reporters with ActiveSupport 3.x, make sure that you require ActiveSupport before invoking `Minitest::Reporters.use!`. Minitest-reporters fixes incompatibilities caused by monkey patches in ActiveSupport 3.x. ActiveSupport 4.x is unaffected.
|
54
53
|
|
55
54
|
## Note on Patches/Pull Requests ##
|
56
55
|
|
data/Rakefile
CHANGED
@@ -21,9 +21,6 @@ end
|
|
21
21
|
|
22
22
|
# - RubyMineReporter must be tested separately inside of RubyMine
|
23
23
|
# - JUnitReporter normally writes to `test/reports` instead of stdout
|
24
|
-
# - GuardReporter requires Guard, and I'm not
|
25
|
-
# really all that interested in setting it up for automated testing for such a
|
26
|
-
# simple reporter.
|
27
24
|
task :gallery do
|
28
25
|
unless rubymine_home
|
29
26
|
warn "To see RubyMineReporter supply RUBYMINE_HOME= or git clone git://git.jetbrains.org/idea/contrib.git ../rubymine-contrib"
|
@@ -36,8 +33,7 @@ task :gallery do
|
|
36
33
|
"ProgressReporter",
|
37
34
|
"RubyMateReporter",
|
38
35
|
"SpecReporter",
|
39
|
-
"RubyMineReporter"
|
40
|
-
"GuardReporter"
|
36
|
+
"RubyMineReporter"
|
41
37
|
].each do |reporter|
|
42
38
|
puts
|
43
39
|
puts "-" * 72
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module
|
1
|
+
module Minitest
|
2
2
|
# Filters backtraces of exceptions that may arise when running tests.
|
3
3
|
class ExtensibleBacktraceFilter
|
4
4
|
# Returns the default filter.
|
5
5
|
#
|
6
|
-
# The default filter will filter out all
|
6
|
+
# The default filter will filter out all Minitest and minitest-reporters
|
7
7
|
# lines.
|
8
8
|
#
|
9
|
-
# @return [
|
9
|
+
# @return [Minitest::ExtensibleBacktraceFilter]
|
10
10
|
def self.default_filter
|
11
11
|
unless defined? @default_filter
|
12
12
|
filter = self.new
|
@@ -48,7 +48,7 @@ module MiniTest
|
|
48
48
|
#
|
49
49
|
# @param [Array] backtrace the backtrace to filter
|
50
50
|
# @return [Array] the filtered backtrace
|
51
|
-
# @note This logic is based off of
|
51
|
+
# @note This logic is based off of Minitest's #filter_backtrace.
|
52
52
|
def filter(backtrace)
|
53
53
|
result = []
|
54
54
|
return result unless backtrace
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Minitest
|
2
|
+
class << self
|
3
|
+
def plugin_minitest_reporter_init(options)
|
4
|
+
if defined?(Minitest::Reporters) && Minitest::Reporters.reporters
|
5
|
+
reporter.reporters = Minitest::Reporters.reporters + guard_reporter
|
6
|
+
reporter.reporters.each do |reporter|
|
7
|
+
reporter.io = options[:io]
|
8
|
+
reporter.add_defaults(options.merge(:total_count => total_count(options)))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# stolen from minitest self.run
|
16
|
+
def total_count(options)
|
17
|
+
filter = options[:filter] || '/./'
|
18
|
+
filter = Regexp.new $1 if filter =~ /\/(.*)\//
|
19
|
+
|
20
|
+
Minitest::Runnable.runnables.map(&:runnable_methods).flatten.find_all { |m|
|
21
|
+
filter === m || filter === "#{self}##{m}"
|
22
|
+
}.size
|
23
|
+
end
|
24
|
+
|
25
|
+
def guard_reporter
|
26
|
+
Array(reporter.reporters.detect { |r| r.class.name == "Guard::Minitest::Reporter" })
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Minitest
|
2
2
|
module RelativePosition
|
3
3
|
TEST_PADDING = 2
|
4
4
|
TEST_SIZE = 63
|
@@ -11,7 +11,7 @@ module MiniTest
|
|
11
11
|
puts pad(line, INFO_PADDING)
|
12
12
|
end
|
13
13
|
|
14
|
-
def pad(str, size)
|
14
|
+
def pad(str, size = INFO_PADDING)
|
15
15
|
' ' * size + str
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Minitest
|
2
|
+
module Reporters
|
3
|
+
class BaseReporter < Minitest::StatisticsReporter
|
4
|
+
attr_accessor :total_count
|
5
|
+
attr_accessor :tests
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
super($stdout, options)
|
9
|
+
self.tests = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_defaults(defaults)
|
13
|
+
self.options = defaults.merge(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
# called by our own before hooks
|
17
|
+
def before_test(test)
|
18
|
+
last_test = tests.last
|
19
|
+
if last_test.class != test.class
|
20
|
+
after_suite(test.class) if last_test
|
21
|
+
before_suite(test.class)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def record(test)
|
26
|
+
super
|
27
|
+
tests << test
|
28
|
+
end
|
29
|
+
|
30
|
+
# called by our own after hooks
|
31
|
+
def after_test(test)
|
32
|
+
end
|
33
|
+
|
34
|
+
def report
|
35
|
+
super
|
36
|
+
after_suite(tests.last.class)
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def after_suite(test)
|
42
|
+
end
|
43
|
+
|
44
|
+
def before_suite(test)
|
45
|
+
end
|
46
|
+
|
47
|
+
def result(test)
|
48
|
+
if test.error?
|
49
|
+
:error
|
50
|
+
elsif test.failure
|
51
|
+
:fail
|
52
|
+
elsif test.skipped?
|
53
|
+
:skip
|
54
|
+
else
|
55
|
+
:pass
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def total_time
|
60
|
+
super || Time.now - start_time
|
61
|
+
end
|
62
|
+
|
63
|
+
def total_count
|
64
|
+
options[:total_count]
|
65
|
+
end
|
66
|
+
|
67
|
+
def filter_backtrace(backtrace)
|
68
|
+
Minitest.filter_backtrace(backtrace)
|
69
|
+
end
|
70
|
+
|
71
|
+
def puts(*args)
|
72
|
+
io.puts(*args)
|
73
|
+
end
|
74
|
+
|
75
|
+
def print(*args)
|
76
|
+
io.print(*args)
|
77
|
+
end
|
78
|
+
|
79
|
+
def print_info(e, name=true)
|
80
|
+
print "#{e.exception.class.to_s}: " if name
|
81
|
+
e.message.each_line { |line| print_with_info_padding(line) }
|
82
|
+
|
83
|
+
trace = filter_backtrace(e.backtrace)
|
84
|
+
trace.each { |line| print_with_info_padding(line) }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,111 +1,81 @@
|
|
1
1
|
require 'ansi/code'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Minitest
|
4
4
|
module Reporters
|
5
|
-
# A reporter identical to the standard
|
5
|
+
# A reporter identical to the standard Minitest reporter except with more
|
6
6
|
# colors.
|
7
7
|
#
|
8
|
-
# Based upon Ryan Davis of Seattle.rb's
|
8
|
+
# Based upon Ryan Davis of Seattle.rb's Minitest (MIT License).
|
9
9
|
#
|
10
|
-
# @see https://github.com/seattlerb/minitest
|
11
|
-
class DefaultReporter
|
12
|
-
include Reporter
|
10
|
+
# @see https://github.com/seattlerb/minitest Minitest
|
11
|
+
class DefaultReporter < BaseReporter
|
13
12
|
include RelativePosition
|
14
13
|
|
15
14
|
def initialize(options = {})
|
15
|
+
super
|
16
16
|
@detailed_skip = options.fetch(:detailed_skip, true)
|
17
17
|
@slow_count = options.fetch(:slow_count, 0)
|
18
18
|
@slow_suite_count = options.fetch(:slow_suite_count, 0)
|
19
19
|
@fast_fail = options.fetch(:fast_fail, false)
|
20
|
-
@
|
21
|
-
@suite_times = []
|
22
|
-
@color = options.fetch(:color) do
|
23
|
-
output.tty? && (
|
24
|
-
ENV["TERM"] =~ /^screen|color/ ||
|
25
|
-
ENV["EMACS"] == "t"
|
26
|
-
)
|
27
|
-
end
|
20
|
+
@options = options
|
28
21
|
end
|
29
22
|
|
30
|
-
def
|
23
|
+
def start
|
24
|
+
super
|
31
25
|
puts
|
32
|
-
puts "# Running
|
26
|
+
puts "# Running tests:"
|
33
27
|
puts
|
34
28
|
end
|
35
29
|
|
36
|
-
def before_test(
|
37
|
-
|
38
|
-
print "#{
|
30
|
+
def before_test(test)
|
31
|
+
super
|
32
|
+
print "\n#{test.class}##{test.name} " if options[:verbose]
|
39
33
|
end
|
40
34
|
|
41
|
-
def
|
42
|
-
|
43
|
-
end
|
35
|
+
def record(test)
|
36
|
+
super
|
44
37
|
|
45
|
-
|
46
|
-
test_result(yellow('S'))
|
47
|
-
end
|
38
|
+
print "#{"%.2f" % test.time} = " if options[:verbose]
|
48
39
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
print_info(test_runner.exception, false)
|
57
|
-
else
|
58
|
-
test_result(red('F'))
|
59
|
-
end
|
60
|
-
end
|
40
|
+
print(if test.passed?
|
41
|
+
green('.')
|
42
|
+
elsif test.skipped?
|
43
|
+
yellow('S')
|
44
|
+
elsif test.failure
|
45
|
+
red('F')
|
46
|
+
end)
|
61
47
|
|
62
|
-
|
63
|
-
if @fast_fail
|
64
|
-
puts
|
65
|
-
puts suite.name
|
66
|
-
print pad_test(test)
|
67
|
-
print(red(pad_mark('ERROR')))
|
48
|
+
if @fast_fail && (test.skipped? || test.failure)
|
68
49
|
puts
|
69
|
-
|
70
|
-
else
|
71
|
-
test_result(red('E'))
|
50
|
+
print_failure(test)
|
72
51
|
end
|
73
52
|
end
|
74
53
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
def after_suites(suites, type)
|
81
|
-
time = Time.now - runner.suites_start_time
|
82
|
-
status_line = "Finished %ss in %.6fs, %.4f tests/s, %.4f assertions/s." %
|
83
|
-
[type, time, runner.test_count / time, runner.assertion_count / time]
|
54
|
+
def report
|
55
|
+
super
|
56
|
+
status_line = "Finished tests in %.6fs, %.4f tests/s, %.4f assertions/s." %
|
57
|
+
[total_time, count / total_time, assertions / total_time]
|
84
58
|
|
85
59
|
puts
|
86
60
|
puts
|
87
61
|
puts colored_for(suite_result, status_line)
|
88
62
|
|
89
63
|
unless @fast_fail
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
puts
|
94
|
-
print colored_for(test_runner.result, message)
|
95
|
-
end
|
96
|
-
end
|
64
|
+
tests.reject(&:passed?).each do |test|
|
65
|
+
puts
|
66
|
+
print_failure(test)
|
97
67
|
end
|
98
68
|
end
|
99
69
|
|
100
70
|
if @slow_count > 0
|
101
|
-
slow_tests =
|
71
|
+
slow_tests = tests.sort_by(&:time).reverse.take(@slow_count)
|
102
72
|
|
103
73
|
puts
|
104
74
|
puts "Slowest tests:"
|
105
75
|
puts
|
106
76
|
|
107
|
-
slow_tests.each do |
|
108
|
-
puts "%.6fs %s" % [
|
77
|
+
slow_tests.each do |test|
|
78
|
+
puts "%.6fs %s" % [test.time, "#{test.name}##{test.class}"]
|
109
79
|
end
|
110
80
|
end
|
111
81
|
|
@@ -126,23 +96,37 @@ module MiniTest
|
|
126
96
|
puts
|
127
97
|
end
|
128
98
|
|
99
|
+
def print_failure(test)
|
100
|
+
puts colored_for(result(test), message_for(test))
|
101
|
+
end
|
102
|
+
|
129
103
|
private
|
130
104
|
|
105
|
+
def color?
|
106
|
+
return @color if defined?(@color)
|
107
|
+
@color = @options.fetch(:color) do
|
108
|
+
io.tty? && (
|
109
|
+
ENV["TERM"] =~ /^screen|color/ ||
|
110
|
+
ENV["EMACS"] == "t"
|
111
|
+
)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
131
115
|
def green(string)
|
132
|
-
|
116
|
+
color? ? ANSI::Code.green(string) : string
|
133
117
|
end
|
134
118
|
|
135
119
|
def yellow(string)
|
136
|
-
|
120
|
+
color? ? ANSI::Code.yellow(string) : string
|
137
121
|
end
|
138
122
|
|
139
123
|
def red(string)
|
140
|
-
|
124
|
+
color? ? ANSI::Code.red(string) : string
|
141
125
|
end
|
142
126
|
|
143
127
|
def colored_for(result, string)
|
144
128
|
case result
|
145
|
-
when :
|
129
|
+
when :fail, :error; red(string)
|
146
130
|
when :skip; yellow(string)
|
147
131
|
else green(string)
|
148
132
|
end
|
@@ -150,22 +134,13 @@ module MiniTest
|
|
150
134
|
|
151
135
|
def suite_result
|
152
136
|
case
|
153
|
-
when
|
154
|
-
when
|
155
|
-
when
|
137
|
+
when failures > 0; :fail
|
138
|
+
when errors > 0; :error
|
139
|
+
when skips > 0; :skip
|
156
140
|
else :pass
|
157
141
|
end
|
158
142
|
end
|
159
143
|
|
160
|
-
def test_result(result)
|
161
|
-
time = Time.now - (runner.test_start_time || Time.now)
|
162
|
-
@test_times << [@test_name, time]
|
163
|
-
|
164
|
-
print '%.2f s = ' % time if verbose?
|
165
|
-
print result
|
166
|
-
puts if verbose?
|
167
|
-
end
|
168
|
-
|
169
144
|
def location(exception)
|
170
145
|
last_before_assertion = ''
|
171
146
|
|
@@ -177,33 +152,24 @@ module MiniTest
|
|
177
152
|
last_before_assertion.sub(/:in .*$/, '')
|
178
153
|
end
|
179
154
|
|
180
|
-
def message_for(
|
181
|
-
|
182
|
-
test = test_runner.test
|
183
|
-
e = test_runner.exception
|
155
|
+
def message_for(test)
|
156
|
+
e = test.failure
|
184
157
|
|
185
|
-
|
186
|
-
when :pass then nil
|
187
|
-
when :skip
|
158
|
+
if test.skipped?
|
188
159
|
if @detailed_skip
|
189
|
-
"Skipped:\n#{test}
|
160
|
+
"Skipped:\n#{test.class}##{test.name} [#{location(e)}]:\n#{e.message}"
|
190
161
|
end
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
162
|
+
elsif test.error?
|
163
|
+
bt = filter_backtrace(e.backtrace).join "\n "
|
164
|
+
"Error:\n#{test.class}##{test.name}:\n#{e.class}: #{e.message}\n #{bt}"
|
165
|
+
else
|
166
|
+
"Failure:\n#{test.class}##{test.name}:\n#{e.class}: #{e.message}"
|
195
167
|
end
|
196
168
|
end
|
197
169
|
|
198
170
|
def result_line
|
199
171
|
'%d tests, %d assertions, %d failures, %d errors, %d skips' %
|
200
|
-
[
|
201
|
-
end
|
202
|
-
|
203
|
-
def print_info(e, name = true)
|
204
|
-
print "#{e.exception.class.to_s}: " if name
|
205
|
-
e.message.each_line { |line| print_with_info_padding(line) }
|
206
|
-
filter_backtrace(e.backtrace).each { |line| print_with_info_padding(line) }
|
172
|
+
[count, assertions, failures, errors, skips]
|
207
173
|
end
|
208
174
|
end
|
209
175
|
end
|