minitest-reporters 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Rakefile +31 -8
- data/lib/minitest/reporters/default_reporter.rb +62 -15
- data/lib/minitest/reporters/version.rb +1 -1
- data/test/gallery/bad_test.rb +25 -0
- data/test/gallery/good_test.rb +14 -0
- data/test/test_helper.rb +12 -15
- data/test/{minitest → unit/minitest}/backtrace_filter_test.rb +1 -1
- data/test/{minitest → unit/minitest}/reporter_test.rb +1 -1
- data/test/{minitest → unit/minitest}/reporters_test.rb +1 -1
- metadata +12 -8
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -1,11 +1,34 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
4
|
task :default => :test
|
5
|
-
|
6
|
-
require 'rake/testtask'
|
7
5
|
Rake::TestTask.new do |t|
|
8
|
-
t.
|
9
|
-
t.
|
10
|
-
|
11
|
-
|
6
|
+
t.pattern = "test/unit/**/*_test.rb"
|
7
|
+
t.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
Rake::TestTask.new("test:gallery") do |t|
|
11
|
+
t.pattern = "test/gallery/**/*_test.rb"
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
# The RubyMine reporter must be tested separately inside of RubyMine, and hence
|
16
|
+
# is not run in the gallery. The JUnit reporter writes to `test/reports` instead
|
17
|
+
# of having meaningful output. The guard reporter requires Guard, and I'm not
|
18
|
+
# really all that intersted in setting it up for automated testing for such a
|
19
|
+
# simple reporter.
|
20
|
+
task :gallery do
|
21
|
+
[
|
22
|
+
"DefaultReporter",
|
23
|
+
"JUnitReporter",
|
24
|
+
"ProgressReporter",
|
25
|
+
"RubyMateReporter",
|
26
|
+
"SpecReporter"
|
27
|
+
].each do |reporter|
|
28
|
+
puts "Running gallery tests using #{reporter}..."
|
29
|
+
sh "rake test:gallery REPORTER=#{reporter}" do
|
30
|
+
# Ignore failures. They're expected when you are running the gallery
|
31
|
+
# test suite.
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -10,8 +10,23 @@ module MiniTest
|
|
10
10
|
class DefaultReporter
|
11
11
|
include Reporter
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
|
13
|
+
def initialize(options = {})
|
14
|
+
if options.is_a?(Hash)
|
15
|
+
@backtrace_filter = options.fetch(:backtrace_filter, BacktraceFilter.default_filter)
|
16
|
+
@detailed_skip = options.fetch(:detailed_skip, true)
|
17
|
+
@color = options.fetch(:color) do
|
18
|
+
output.tty? && (
|
19
|
+
ENV["TERM"] == "screen" ||
|
20
|
+
ENV["TERM"] =~ /term(?:-(?:256)?color)?\z/ ||
|
21
|
+
ENV["EMACS"] == "t"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
warn "Please use :backtrace_filter => filter instead of passing in the filter directly."
|
26
|
+
@backtrace_filter = options
|
27
|
+
@detailed_skip = true
|
28
|
+
@color = false
|
29
|
+
end
|
15
30
|
end
|
16
31
|
|
17
32
|
def before_suites(suites, type)
|
@@ -25,46 +40,75 @@ module MiniTest
|
|
25
40
|
end
|
26
41
|
|
27
42
|
def pass(suite, test, test_runner)
|
28
|
-
after_test('.')
|
43
|
+
after_test(green { '.' })
|
29
44
|
end
|
30
45
|
|
31
46
|
def skip(suite, test, test_runner)
|
32
|
-
after_test('S')
|
47
|
+
after_test(yellow { 'S' })
|
33
48
|
end
|
34
49
|
|
35
50
|
def failure(suite, test, test_runner)
|
36
|
-
after_test('F')
|
51
|
+
after_test(red { 'F' })
|
37
52
|
end
|
38
53
|
|
39
54
|
def error(suite, test, test_runner)
|
40
|
-
after_test('E')
|
55
|
+
after_test(red { 'E' })
|
41
56
|
end
|
42
57
|
|
43
58
|
def after_suites(suites, type)
|
44
59
|
time = Time.now - runner.suites_start_time
|
60
|
+
status_line = colored_for(suite_result) do
|
61
|
+
"Finished %ss in %.6fs, %.4f tests/s, %.4f assertions/s." %
|
62
|
+
[type, time, runner.test_count / time, runner.assertion_count / time]
|
63
|
+
end
|
45
64
|
|
46
65
|
puts
|
47
66
|
puts
|
48
|
-
puts
|
49
|
-
[time, runner.test_count / time, runner.assertion_count / time]
|
67
|
+
puts status_line
|
50
68
|
|
51
|
-
i = 0
|
52
69
|
runner.test_results.each do |suite, tests|
|
53
70
|
tests.each do |test, test_runner|
|
54
|
-
message = message_for(test_runner)
|
55
|
-
|
56
|
-
|
57
|
-
puts "\n%3d) %s" % [i, message]
|
71
|
+
if message = message_for(test_runner)
|
72
|
+
puts
|
73
|
+
print(colored_for(test_runner.result) { message })
|
58
74
|
end
|
59
75
|
end
|
60
76
|
end
|
61
77
|
|
62
78
|
puts
|
63
|
-
puts status
|
79
|
+
puts(colored_for(suite_result) { status })
|
64
80
|
end
|
65
81
|
|
66
82
|
private
|
67
83
|
|
84
|
+
def green(&block)
|
85
|
+
@color ? ANSI::Code.green(&block) : yield
|
86
|
+
end
|
87
|
+
|
88
|
+
def yellow(&block)
|
89
|
+
@color ? ANSI::Code.yellow(&block) : yield
|
90
|
+
end
|
91
|
+
|
92
|
+
def red(&block)
|
93
|
+
@color ? ANSI::Code.red(&block) : yield
|
94
|
+
end
|
95
|
+
|
96
|
+
def colored_for(result, &block)
|
97
|
+
case result
|
98
|
+
when :failure, :error; red(&block)
|
99
|
+
when :skip; yellow(&block)
|
100
|
+
else green(&block)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def suite_result
|
105
|
+
if runner.failures > 0; :failure
|
106
|
+
elsif runner.errors > 0; :error
|
107
|
+
elsif runner.skips > 0; :skip
|
108
|
+
else :pass
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
68
112
|
def after_test(result)
|
69
113
|
time = Time.now - runner.test_start_time
|
70
114
|
|
@@ -91,7 +135,10 @@ module MiniTest
|
|
91
135
|
|
92
136
|
case test_runner.result
|
93
137
|
when :pass then nil
|
94
|
-
when :skip
|
138
|
+
when :skip
|
139
|
+
if @detailed_skip
|
140
|
+
"Skipped:\n#{test}(#{suite}) [#{location(e)}]:\n#{e.message}\n"
|
141
|
+
end
|
95
142
|
when :failure then "Failure:\n#{test}(#{suite}) [#{location(e)}]:\n#{e.message}\n"
|
96
143
|
when :error
|
97
144
|
bt = @backtrace_filter.filter(test_runner.exception.backtrace).join "\n "
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative "../test_helper"
|
2
|
+
|
3
|
+
module MiniTestReportersTest
|
4
|
+
class BadTest < TestCase
|
5
|
+
def test_a
|
6
|
+
assert_equal 1, 2
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_b
|
10
|
+
assert false # simple failure
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_b
|
14
|
+
assert_equal "ab\nc", "ab\nd" # some nice diff
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_boom
|
18
|
+
raise "A random exception"
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_long_method_name
|
22
|
+
skip
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "bundler/setup"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "rr"
|
4
|
+
require "minitest/reporters"
|
5
5
|
|
6
6
|
module MiniTestReportersTest
|
7
7
|
class TestCase < MiniTest::Unit::TestCase
|
@@ -10,15 +10,12 @@ module MiniTestReportersTest
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Testing the built-in reporters using automated unit testing would be extremely
|
13
|
-
# brittle. Consequently, there are no unit tests for them.
|
14
|
-
# the
|
15
|
-
# try them with skipped, failing, and error tests as well!
|
13
|
+
# brittle. Consequently, there are no unit tests for them. If you'd like to run
|
14
|
+
# all the reporters sequentially on a fake test suite, run `rake gallery`.
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# MiniTest::Reporters.use! MiniTest::Reporters::GuardReporter.new
|
24
|
-
# MiniTest::Reporters.use! MiniTest::Reporters::JUnitReporter.new
|
16
|
+
if ENV["REPORTER"]
|
17
|
+
reporter_klass = MiniTest::Reporters.const_get(ENV["REPORTER"])
|
18
|
+
MiniTest::Reporters.use! [reporter_klass.new]
|
19
|
+
else
|
20
|
+
MiniTest::Reporters.use!
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-reporters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -158,10 +158,12 @@ files:
|
|
158
158
|
- lib/minitest/reporters/version.rb
|
159
159
|
- lib/minitest/test_runner.rb
|
160
160
|
- minitest-reporters.gemspec
|
161
|
-
- test/
|
162
|
-
- test/
|
163
|
-
- test/minitest/reporters_test.rb
|
161
|
+
- test/gallery/bad_test.rb
|
162
|
+
- test/gallery/good_test.rb
|
164
163
|
- test/test_helper.rb
|
164
|
+
- test/unit/minitest/backtrace_filter_test.rb
|
165
|
+
- test/unit/minitest/reporter_test.rb
|
166
|
+
- test/unit/minitest/reporters_test.rb
|
165
167
|
homepage: https://github.com/CapnKernul/minitest-reporters
|
166
168
|
licenses: []
|
167
169
|
post_install_message:
|
@@ -187,8 +189,10 @@ signing_key:
|
|
187
189
|
specification_version: 3
|
188
190
|
summary: Create customizable MiniTest output formats
|
189
191
|
test_files:
|
190
|
-
- test/
|
191
|
-
- test/
|
192
|
-
- test/minitest/reporters_test.rb
|
192
|
+
- test/gallery/bad_test.rb
|
193
|
+
- test/gallery/good_test.rb
|
193
194
|
- test/test_helper.rb
|
195
|
+
- test/unit/minitest/backtrace_filter_test.rb
|
196
|
+
- test/unit/minitest/reporter_test.rb
|
197
|
+
- test/unit/minitest/reporters_test.rb
|
194
198
|
has_rdoc:
|