minitest-reporters 0.14.24 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,15 +0,0 @@
|
|
1
|
-
module MiniTest
|
2
|
-
module AroundTestHooks
|
3
|
-
def self.before_test(instance)
|
4
|
-
MiniTest::Unit.runner.before_test(instance.class, instance.__name__)
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.after_test(instance)
|
8
|
-
# MiniTest < 4.1.0 sends #record after all teardown hooks, so don't call
|
9
|
-
# #after_test here.
|
10
|
-
if MiniTest::Unit::VERSION > "4.1.0"
|
11
|
-
MiniTest::Unit.runner.after_test(instance.class, instance.__name__)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/minitest/reporter.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module MiniTest
|
2
|
-
module Reporter
|
3
|
-
def runner
|
4
|
-
Unit.runner
|
5
|
-
end
|
6
|
-
|
7
|
-
def filter_backtrace(backtrace)
|
8
|
-
MiniTest.filter_backtrace(backtrace)
|
9
|
-
end
|
10
|
-
|
11
|
-
def output
|
12
|
-
runner.output
|
13
|
-
end
|
14
|
-
|
15
|
-
def verbose?
|
16
|
-
runner.verbose
|
17
|
-
end
|
18
|
-
|
19
|
-
def print(*args)
|
20
|
-
runner.output.print(*args)
|
21
|
-
end
|
22
|
-
|
23
|
-
def puts(*args)
|
24
|
-
runner.output.puts(*args)
|
25
|
-
end
|
26
|
-
|
27
|
-
def before_suites(suites, type); end
|
28
|
-
def after_suites(suites, type); end
|
29
|
-
def before_suite(suite); end
|
30
|
-
def after_suite(suite); end
|
31
|
-
def before_test(suite, test); end
|
32
|
-
def after_test(suite, test); end
|
33
|
-
def pass(suite, test, test_runner); end
|
34
|
-
def skip(suite, test, test_runner); end
|
35
|
-
def failure(suite, test, test_runner); end
|
36
|
-
def error(suite, test, test_runner); end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module MiniTest
|
4
|
-
# Runner for MiniTest that supports reporters.
|
5
|
-
#
|
6
|
-
# Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
|
7
|
-
#
|
8
|
-
# @see https://github.com/seattlerb/minitest MiniTest
|
9
|
-
class ReporterRunner < Unit
|
10
|
-
extend Forwardable
|
11
|
-
|
12
|
-
attr_accessor :reporters
|
13
|
-
attr_reader :test_results
|
14
|
-
attr_reader :suites_start_time
|
15
|
-
attr_reader :suite_start_time
|
16
|
-
attr_reader :test_start_time
|
17
|
-
|
18
|
-
def_delegator :@test_recorder, :assertion_count
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
super
|
22
|
-
self.reporters = []
|
23
|
-
@test_results = {}
|
24
|
-
@test_recorder = TestRecorder.new
|
25
|
-
@allow_default_output = true
|
26
|
-
end
|
27
|
-
|
28
|
-
def run_tests
|
29
|
-
@allow_default_output = false
|
30
|
-
super
|
31
|
-
end
|
32
|
-
|
33
|
-
def _run_suites(suites, type)
|
34
|
-
@suites_start_time = Time.now
|
35
|
-
count_tests!(suites, type)
|
36
|
-
trigger_callback(:before_suites, suites, type)
|
37
|
-
super(suites, type)
|
38
|
-
ensure
|
39
|
-
trigger_callback(:after_suites, suites, type)
|
40
|
-
end
|
41
|
-
|
42
|
-
def _run_suite(suite, type)
|
43
|
-
@suite_start_time = Time.now
|
44
|
-
trigger_callback(:before_suite, suite)
|
45
|
-
super(suite, type)
|
46
|
-
ensure
|
47
|
-
trigger_callback(:after_suite, suite)
|
48
|
-
end
|
49
|
-
|
50
|
-
def before_test(suite, test)
|
51
|
-
@test_start_time = Time.now
|
52
|
-
trigger_callback(:before_test, suite, test)
|
53
|
-
end
|
54
|
-
|
55
|
-
def record(suite, test, assertions, time, exception)
|
56
|
-
runner = TestRunner.new(suite,
|
57
|
-
test.to_sym,
|
58
|
-
assertions,
|
59
|
-
time,
|
60
|
-
exception)
|
61
|
-
|
62
|
-
@test_results[suite] ||= {}
|
63
|
-
@test_results[suite][test.to_sym] = runner
|
64
|
-
@test_recorder.record(runner)
|
65
|
-
|
66
|
-
# MiniTest < 4.1.0 sends #record after all teardown hooks, so explicitly
|
67
|
-
# call #after_test here after recording.
|
68
|
-
after_test(suite, test) if Unit::VERSION <= "4.1.0"
|
69
|
-
end
|
70
|
-
|
71
|
-
def after_test(suite, test)
|
72
|
-
runners = @test_recorder[suite, test.to_sym]
|
73
|
-
|
74
|
-
runners.each do |runner|
|
75
|
-
trigger_callback(runner.result, suite, test.to_sym, runner)
|
76
|
-
end
|
77
|
-
|
78
|
-
trigger_callback(:after_test, suite, test.to_sym)
|
79
|
-
end
|
80
|
-
|
81
|
-
# Stub out the three IO methods used by the built-in reporter.
|
82
|
-
def puts(*args)
|
83
|
-
super if @allow_default_output
|
84
|
-
end
|
85
|
-
|
86
|
-
def print(*args)
|
87
|
-
super if @allow_default_output
|
88
|
-
end
|
89
|
-
|
90
|
-
def status(io = output)
|
91
|
-
super if @allow_default_output
|
92
|
-
end
|
93
|
-
|
94
|
-
private
|
95
|
-
|
96
|
-
def trigger_callback(callback, *args)
|
97
|
-
reporters.each { |r| r.public_send(callback, *args) }
|
98
|
-
end
|
99
|
-
|
100
|
-
def count_tests!(suites, type)
|
101
|
-
filter = options[:filter] || '/./'
|
102
|
-
filter = Regexp.new $1 if filter =~ /\/(.*)\//
|
103
|
-
|
104
|
-
@test_count = suites.inject(0) do |acc, suite|
|
105
|
-
acc + suite.send("#{type}_methods").grep(filter).length
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require "guard/minitest/notifier"
|
3
|
-
rescue LoadError
|
4
|
-
puts "You need guard-minitest to use this reporter."
|
5
|
-
exit 1
|
6
|
-
end
|
7
|
-
|
8
|
-
module MiniTest
|
9
|
-
module Reporters
|
10
|
-
class GuardReporter
|
11
|
-
include Reporter
|
12
|
-
|
13
|
-
def notifier_class
|
14
|
-
if ::Guard.const_defined? "MinitestNotifier"
|
15
|
-
# old guard-minitest API prior to 1.0.0.beta.2
|
16
|
-
::Guard::MinitestNotifier
|
17
|
-
elsif ::Guard.const_defined? "Minitest" and ::Guard::Minitest.const_defined? "Notifier"
|
18
|
-
# new guard-minitest API, by 02b46ee in between
|
19
|
-
# 1.0.0.beta1 and 1.0.0.beta.2
|
20
|
-
::Guard::Minitest::Notifier
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def after_suites(*args)
|
25
|
-
duration = Time.now - runner.suites_start_time
|
26
|
-
notifier_class.notify(runner.test_count, runner.assertion_count,
|
27
|
-
runner.failures, runner.errors,
|
28
|
-
runner.skips, duration)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module MiniTest
|
2
|
-
class TestRecorder
|
3
|
-
def initialize
|
4
|
-
@records = {}
|
5
|
-
end
|
6
|
-
|
7
|
-
def [](suite, test)
|
8
|
-
name = [suite, test]
|
9
|
-
@records[name]
|
10
|
-
end
|
11
|
-
|
12
|
-
def record(runner)
|
13
|
-
name = [runner.suite, runner.test]
|
14
|
-
@records[name] ||= []
|
15
|
-
@records[name] << runner
|
16
|
-
end
|
17
|
-
|
18
|
-
def assertion_count
|
19
|
-
@records.inject(0) { |acc, r| acc + r.last.last.assertions }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/minitest/test_runner.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
module MiniTestReportersTest
|
4
|
-
class ReporterTest < TestCase
|
5
|
-
def setup
|
6
|
-
klass = Class.new do
|
7
|
-
include MiniTest::Reporter
|
8
|
-
end
|
9
|
-
|
10
|
-
@reporter = klass.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_callbacks
|
14
|
-
[
|
15
|
-
:before_suites, :after_suite, :before_suite, :after_suite, :before_test, :after_test,
|
16
|
-
:pass, :skip, :failure, :error
|
17
|
-
].each { |method| assert_respond_to @reporter, method }
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_runner
|
21
|
-
assert_kind_of MiniTest::Unit, @reporter.runner
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_output
|
25
|
-
assert_equal MiniTest::Unit.output, @reporter.output
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_verbose
|
29
|
-
refute @reporter.verbose?
|
30
|
-
|
31
|
-
begin
|
32
|
-
@reporter.runner.verbose = true
|
33
|
-
assert @reporter.verbose?
|
34
|
-
ensure
|
35
|
-
@reporter.runner.verbose = false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|