minitest-reporters 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -4
- data/lib/minitest/before_test_hook.rb +16 -0
- data/lib/minitest/reporter.rb +5 -5
- data/lib/minitest/reporter_runner.rb +86 -0
- data/lib/minitest/reporters.rb +17 -5
- data/lib/minitest/reporters/default_reporter.rb +2 -3
- data/lib/minitest/reporters/guard_reporter.rb +1 -1
- data/lib/minitest/reporters/junit_reporter.rb +6 -6
- data/lib/minitest/reporters/progress_reporter.rb +2 -2
- data/lib/minitest/reporters/ruby_mate_reporter.rb +1 -1
- data/lib/minitest/reporters/rubymine_reporter.rb +1 -10
- data/lib/minitest/reporters/spec_reporter.rb +18 -9
- data/lib/minitest/reporters/version.rb +1 -1
- data/lib/minitest/test_runner.rb +1 -37
- data/minitest-reporters.gemspec +2 -3
- data/test/minitest/backtrace_filter_test.rb +5 -5
- data/test/minitest/reporter_test.rb +16 -16
- data/test/minitest/reporters_test.rb +4 -4
- data/test/test_helper.rb +3 -12
- metadata +9 -44
- data/lib/minitest/suite_runner.rb +0 -110
- data/test/minitest/suite_runner_test.rb +0 -164
- data/test/minitest/test_runner_test.rb +0 -91
- data/test/support/fixtures/empty_test_fixture.rb +0 -5
- data/test/support/fixtures/error_test_fixture.rb +0 -9
- data/test/support/fixtures/failure_test_fixture.rb +0 -9
- data/test/support/fixtures/pass_test_fixture.rb +0 -14
- data/test/support/fixtures/skip_test_fixture.rb +0 -9
- data/test/support/fixtures/suite_callback_test_fixture.rb +0 -9
- data/test/support/fixtures/test_case_fixture.rb +0 -38
- data/test/support/test_case.rb +0 -4
data/README.md
CHANGED
@@ -32,10 +32,6 @@ The following reporters are provided:
|
|
32
32
|
MiniTest::Reporters::RubyMineReporter # => Reporter designed for RubyMine IDE and TeamCity CI server; see below
|
33
33
|
MiniTest::Reporters::GuardReporter # => Integrates with guard-minitest to provide on-screen notifications
|
34
34
|
|
35
|
-
## TODO ##
|
36
|
-
|
37
|
-
* Add some example images of the reporters.
|
38
|
-
|
39
35
|
## Note on Patches/Pull Requests ##
|
40
36
|
|
41
37
|
* Fork the project.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MiniTest
|
2
|
+
module BeforeTestHook
|
3
|
+
def self.before_test(instance)
|
4
|
+
runner = MiniTest::Unit.runner
|
5
|
+
|
6
|
+
if runner.respond_to?(:before_test)
|
7
|
+
runner.before_test(instance.class, instance.__name__)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def before_setup
|
12
|
+
BeforeTestHook.before_test(self)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/minitest/reporter.rb
CHANGED
@@ -3,23 +3,23 @@ module MiniTest
|
|
3
3
|
def runner
|
4
4
|
Unit.runner
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def output
|
8
8
|
runner.output
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def verbose?
|
12
12
|
runner.verbose
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def print(*args)
|
16
16
|
runner.output.print(*args)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def puts(*args)
|
20
20
|
runner.output.puts(*args)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def before_suites(suites, type); end
|
24
24
|
def after_suites(suites, type); end
|
25
25
|
def before_suite(suite); end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module MiniTest
|
2
|
+
# Runner for MiniTest that supports reporters.
|
3
|
+
#
|
4
|
+
# Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
|
5
|
+
#
|
6
|
+
# @see https://github.com/seattlerb/minitest MiniTest
|
7
|
+
class ReporterRunner < Unit
|
8
|
+
attr_accessor :suites_start_time, :test_start_time, :reporters, :test_results
|
9
|
+
|
10
|
+
alias_method :suite_start_time, :start_time
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
self.reporters = []
|
15
|
+
self.test_results = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def _run_suites(suites, type)
|
19
|
+
self.suites_start_time = Time.now
|
20
|
+
count_tests!(suites, type)
|
21
|
+
trigger_callback(:before_suites, suites, type)
|
22
|
+
super(suites, type)
|
23
|
+
ensure
|
24
|
+
trigger_callback(:after_suites, suites, type)
|
25
|
+
end
|
26
|
+
|
27
|
+
def _run_suite(suite, type)
|
28
|
+
trigger_callback(:before_suite, suite)
|
29
|
+
super(suite, type)
|
30
|
+
ensure
|
31
|
+
trigger_callback(:after_suite, suite)
|
32
|
+
end
|
33
|
+
|
34
|
+
def before_test(suite, test)
|
35
|
+
self.test_start_time = Time.now
|
36
|
+
trigger_callback(:before_test, suite, test)
|
37
|
+
end
|
38
|
+
|
39
|
+
def record(suite, test, assertions, time, exception)
|
40
|
+
result = case exception
|
41
|
+
when nil then :pass
|
42
|
+
when Skip then :skip
|
43
|
+
when Assertion then :failure
|
44
|
+
else :error
|
45
|
+
end
|
46
|
+
|
47
|
+
test_runner = TestRunner.new(
|
48
|
+
suite,
|
49
|
+
test.to_sym,
|
50
|
+
assertions,
|
51
|
+
time,
|
52
|
+
result,
|
53
|
+
exception
|
54
|
+
)
|
55
|
+
|
56
|
+
test_results[suite] ||= {}
|
57
|
+
test_results[suite][test.to_sym] = test_runner
|
58
|
+
trigger_callback(result, suite, test, test_runner)
|
59
|
+
end
|
60
|
+
|
61
|
+
def puts(*args)
|
62
|
+
end
|
63
|
+
|
64
|
+
def print(*args)
|
65
|
+
end
|
66
|
+
|
67
|
+
def status(io = output)
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def trigger_callback(callback, *args)
|
73
|
+
reporters.each do |reporter|
|
74
|
+
reporter.public_send(callback, *args)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def count_tests!(suites, type)
|
79
|
+
filter = options[:filter] || '/./'
|
80
|
+
filter = Regexp.new $1 if filter =~ /\/(.*)\//
|
81
|
+
self.test_count = suites.inject(0) do |acc, suite|
|
82
|
+
acc + suite.send("#{type}_methods").grep(filter).length
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/minitest/reporters.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require "minitest/unit"
|
2
2
|
|
3
3
|
module MiniTest
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
require "minitest/reporter"
|
5
|
+
require "minitest/reporter_runner"
|
6
|
+
require "minitest/before_test_hook"
|
7
|
+
require "minitest/test_runner"
|
8
|
+
require "minitest/backtrace_filter"
|
8
9
|
|
9
10
|
module Reporters
|
10
11
|
require "minitest/reporters/version"
|
@@ -18,11 +19,22 @@ module MiniTest
|
|
18
19
|
autoload :JUnitReporter, "minitest/reporters/junit_reporter"
|
19
20
|
|
20
21
|
def self.use!(console_reporters = ProgressReporter.new, env = ENV)
|
21
|
-
|
22
|
+
include_hook!
|
23
|
+
runner = ReporterRunner.new
|
22
24
|
runner.reporters = choose_reporters(console_reporters, env)
|
23
25
|
Unit.runner = runner
|
24
26
|
end
|
25
27
|
|
28
|
+
def self.include_hook!
|
29
|
+
if Unit::VERSION >= "3.3.0"
|
30
|
+
Unit::TestCase.send(:include, BeforeTestHook)
|
31
|
+
else
|
32
|
+
Unit::TestCase.send(:define_method, :before_setup) do
|
33
|
+
BeforeTestHook.before_test(self)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
26
38
|
def self.choose_reporters(console_reporters, env)
|
27
39
|
if env["TM_PID"]
|
28
40
|
[RubyMateReporter.new]
|
@@ -41,7 +41,7 @@ module MiniTest
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def after_suites(suites, type)
|
44
|
-
time = Time.now - runner.
|
44
|
+
time = Time.now - runner.suites_start_time
|
45
45
|
|
46
46
|
puts
|
47
47
|
puts
|
@@ -49,7 +49,7 @@ module MiniTest
|
|
49
49
|
[time, runner.test_count / time, runner.assertion_count / time]
|
50
50
|
|
51
51
|
i = 0
|
52
|
-
runner.
|
52
|
+
runner.test_results.each do |suite, tests|
|
53
53
|
tests.each do |test, test_runner|
|
54
54
|
message = message_for(test_runner)
|
55
55
|
if message
|
@@ -60,7 +60,6 @@ module MiniTest
|
|
60
60
|
end
|
61
61
|
|
62
62
|
puts
|
63
|
-
|
64
63
|
puts status
|
65
64
|
end
|
66
65
|
|
@@ -11,7 +11,7 @@ module MiniTest
|
|
11
11
|
include Reporter
|
12
12
|
|
13
13
|
def after_suites(*args)
|
14
|
-
duration = Time.now - runner.
|
14
|
+
duration = Time.now - runner.suites_start_time
|
15
15
|
::Guard::MinitestNotifier.notify(runner.test_count, runner.assertion_count,
|
16
16
|
runner.failures, runner.errors,
|
17
17
|
runner.skips, duration)
|
@@ -15,14 +15,14 @@ module MiniTest
|
|
15
15
|
def initialize(reports_dir = "test/reports", backtrace_filter = BacktraceFilter.default_filter)
|
16
16
|
@backtrace_filter = backtrace_filter
|
17
17
|
@reports_path = File.join(Dir.getwd, reports_dir)
|
18
|
-
|
18
|
+
puts "Emptying #{@reports_path}"
|
19
19
|
FileUtils.remove_dir(@reports_path) if File.exists?(@reports_path)
|
20
20
|
FileUtils.mkdir_p(@reports_path)
|
21
21
|
end
|
22
22
|
|
23
23
|
def after_suites(suites, type)
|
24
|
-
|
25
|
-
runner.
|
24
|
+
puts "Writing XML reports to #{@reports_path}"
|
25
|
+
runner.test_results.each do |suite, tests|
|
26
26
|
suite_result = analyze_suite(suite, tests)
|
27
27
|
|
28
28
|
xml = Builder::XmlMarkup.new(:indent => 2)
|
@@ -51,7 +51,7 @@ module MiniTest
|
|
51
51
|
e = test_runner.exception
|
52
52
|
|
53
53
|
case test_runner.result
|
54
|
-
when :skip
|
54
|
+
when :skip
|
55
55
|
xml.skipped(:type => test)
|
56
56
|
when :error
|
57
57
|
xml.error(:type => test, :message => xml.trunc!(e.message)) do
|
@@ -79,7 +79,7 @@ module MiniTest
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
|
83
83
|
def location(exception)
|
84
84
|
last_before_assertion = ''
|
85
85
|
exception.backtrace.reverse_each do |s|
|
@@ -105,7 +105,7 @@ module MiniTest
|
|
105
105
|
while File.exists?(File.join(@reports_path, filename)) # restrict number of tries, to avoid infinite loops
|
106
106
|
file_counter += 1
|
107
107
|
filename = "TEST-#{suite}-#{file_counter}.xml"
|
108
|
-
|
108
|
+
puts "Too many duplicate files, overwriting earlier report #{filename}" and break if file_counter >= 99
|
109
109
|
end
|
110
110
|
File.join(@reports_path, filename)
|
111
111
|
end
|
@@ -46,7 +46,7 @@ module MiniTest
|
|
46
46
|
@progress.show({
|
47
47
|
:msg => "#{@finished_count}/#{runner.test_count}",
|
48
48
|
:done => @finished_count,
|
49
|
-
:total => runner.test_count
|
49
|
+
:total => runner.test_count,
|
50
50
|
}, true)
|
51
51
|
end
|
52
52
|
|
@@ -94,7 +94,7 @@ module MiniTest
|
|
94
94
|
def after_suites(suites, type)
|
95
95
|
@progress.close
|
96
96
|
|
97
|
-
total_time = Time.now - runner.
|
97
|
+
total_time = Time.now - runner.suites_start_time
|
98
98
|
|
99
99
|
wipe
|
100
100
|
puts
|
@@ -1,14 +1,5 @@
|
|
1
1
|
# Test results reporter for RubyMine IDE (http://www.jetbrains.com/ruby/) and
|
2
2
|
# TeamCity(http://www.jetbrains.com/teamcity/) Continuous Integration Server
|
3
|
-
#
|
4
|
-
# Usage:
|
5
|
-
# # in test_helper.rb
|
6
|
-
# ...
|
7
|
-
# if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
|
8
|
-
# MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new
|
9
|
-
# else
|
10
|
-
# MiniTest::Unit.runner.reporters << MiniTest::Reporters::DefaultReporter.new
|
11
|
-
# end
|
12
3
|
|
13
4
|
require "ansi"
|
14
5
|
begin
|
@@ -81,7 +72,7 @@ else
|
|
81
72
|
end
|
82
73
|
|
83
74
|
def after_suites(suites, type)
|
84
|
-
total_time = Time.now - runner.
|
75
|
+
total_time = Time.now - runner.suites_start_time
|
85
76
|
|
86
77
|
puts('Finished in %.5fs' % total_time)
|
87
78
|
print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
|
@@ -13,8 +13,9 @@ module MiniTest
|
|
13
13
|
include ANSI::Code
|
14
14
|
|
15
15
|
TEST_PADDING = 2
|
16
|
+
TEST_SIZE = 63
|
17
|
+
MARK_SIZE = 5
|
16
18
|
INFO_PADDING = 8
|
17
|
-
MARK_SIZE = 5
|
18
19
|
|
19
20
|
def initialize(backtrace_filter = BacktraceFilter.default_filter)
|
20
21
|
@backtrace_filter = backtrace_filter
|
@@ -26,7 +27,7 @@ module MiniTest
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def after_suites(suites, type)
|
29
|
-
total_time = Time.now - runner.
|
30
|
+
total_time = Time.now - runner.suites_start_time
|
30
31
|
|
31
32
|
puts('Finished in %.5fs' % total_time)
|
32
33
|
print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
|
@@ -43,21 +44,25 @@ module MiniTest
|
|
43
44
|
puts
|
44
45
|
end
|
45
46
|
|
47
|
+
def before_test(suite, test)
|
48
|
+
print pad_test(test)
|
49
|
+
end
|
50
|
+
|
46
51
|
def pass(suite, test, test_runner)
|
47
52
|
print(green { pad_mark('PASS') })
|
48
|
-
|
53
|
+
print_time(test)
|
49
54
|
puts
|
50
55
|
end
|
51
56
|
|
52
57
|
def skip(suite, test, test_runner)
|
53
58
|
print(yellow { pad_mark('SKIP') })
|
54
|
-
|
59
|
+
print_time(test)
|
55
60
|
puts
|
56
61
|
end
|
57
62
|
|
58
63
|
def failure(suite, test, test_runner)
|
59
64
|
print(red { pad_mark('FAIL') })
|
60
|
-
|
65
|
+
print_time(test)
|
61
66
|
puts
|
62
67
|
print_info(test_runner.exception)
|
63
68
|
puts
|
@@ -65,7 +70,7 @@ module MiniTest
|
|
65
70
|
|
66
71
|
def error(suite, test, test_runner)
|
67
72
|
print(red { pad_mark('ERROR') })
|
68
|
-
|
73
|
+
print_time(test)
|
69
74
|
puts
|
70
75
|
print_info(test_runner.exception)
|
71
76
|
puts
|
@@ -73,9 +78,9 @@ module MiniTest
|
|
73
78
|
|
74
79
|
private
|
75
80
|
|
76
|
-
def
|
81
|
+
def print_time(test)
|
77
82
|
total_time = Time.now - runner.test_start_time
|
78
|
-
print("
|
83
|
+
print(" (%.2fs)" % total_time)
|
79
84
|
end
|
80
85
|
|
81
86
|
def print_info(e)
|
@@ -90,7 +95,11 @@ module MiniTest
|
|
90
95
|
end
|
91
96
|
|
92
97
|
def pad_mark(str)
|
93
|
-
|
98
|
+
"%#{MARK_SIZE}s" % str
|
99
|
+
end
|
100
|
+
|
101
|
+
def pad_test(str)
|
102
|
+
pad("%-#{TEST_SIZE}s" % str, TEST_PADDING)
|
94
103
|
end
|
95
104
|
end
|
96
105
|
end
|
data/lib/minitest/test_runner.rb
CHANGED
@@ -1,39 +1,3 @@
|
|
1
1
|
module MiniTest
|
2
|
-
|
3
|
-
#
|
4
|
-
# You *should not* create instances of this class directly. Instances of
|
5
|
-
# {SuiteRunner} will create these and send them to the reporters.
|
6
|
-
#
|
7
|
-
# Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
|
8
|
-
#
|
9
|
-
# @see https://github.com/seattlerb/minitest MiniTest
|
10
|
-
class TestRunner
|
11
|
-
attr_reader :suite, :test, :assertions, :result, :exception, :options
|
12
|
-
|
13
|
-
def initialize(suite, test)
|
14
|
-
@suite = suite
|
15
|
-
@test = test
|
16
|
-
@assertions = 0
|
17
|
-
end
|
18
|
-
|
19
|
-
def run
|
20
|
-
suite_instance = suite.new(test)
|
21
|
-
@result, @exception = fix_result(suite_instance.run(self))
|
22
|
-
@assertions = suite_instance._assertions
|
23
|
-
end
|
24
|
-
|
25
|
-
def puke(suite, test, exception)
|
26
|
-
case exception
|
27
|
-
when Skip then [:skip, exception]
|
28
|
-
when Assertion then [:failure, exception]
|
29
|
-
else [:error, exception]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def fix_result(result)
|
36
|
-
result == '.' ? [:pass, nil] : result
|
37
|
-
end
|
38
|
-
end
|
2
|
+
TestRunner = Struct.new(:suite, :test, :assertions, :time, :result, :exception)
|
39
3
|
end
|
data/minitest-reporters.gemspec
CHANGED
@@ -14,14 +14,13 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.rubyforge_project = 'minitest-reporters'
|
16
16
|
|
17
|
-
s.add_dependency 'minitest', '>= 2.
|
17
|
+
s.add_dependency 'minitest', '>= 2.12', '< 4.0'
|
18
18
|
s.add_dependency 'ansi'
|
19
19
|
s.add_dependency 'powerbar'
|
20
20
|
s.add_dependency 'builder'
|
21
21
|
|
22
|
-
s.add_development_dependency '
|
22
|
+
s.add_development_dependency 'rr'
|
23
23
|
s.add_development_dependency 'maruku'
|
24
|
-
s.add_development_dependency 'test_declarative'
|
25
24
|
s.add_development_dependency 'rake'
|
26
25
|
|
27
26
|
s.files = `git ls-files`.split("\n")
|
@@ -8,28 +8,28 @@ module MiniTestReportersTest
|
|
8
8
|
@backtrace = ["foo", "bar", "baz"]
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
def test_adding_filters
|
12
12
|
@filter.add_filter(/foo/)
|
13
13
|
assert @filter.filters?("foo")
|
14
14
|
refute @filter.filters?("baz")
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
def test_filter_backtrace_when_first_line_is_filtered
|
18
18
|
@filter.add_filter(/foo/)
|
19
19
|
assert_equal ["bar", "baz"], @filter.filter(@backtrace)
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
def test_filter_backtrace_when_middle_line_is_filtered
|
23
23
|
@filter.add_filter(/bar/)
|
24
24
|
assert_equal ["foo"], @filter.filter(@backtrace)
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
def test_filter_backtrace_when_all_lines_are_filtered
|
28
28
|
@filter.add_filter(/./)
|
29
29
|
assert_equal ["foo", "bar", "baz"], @filter.filter(@backtrace)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
def test_default_filter
|
33
33
|
assert @default_filter.filters?("lib/minitest")
|
34
34
|
assert @default_filter.filters?("lib/minitest/reporters")
|
35
35
|
refute @default_filter.filters?("lib/my_gem")
|
@@ -6,28 +6,28 @@ module MiniTestReportersTest
|
|
6
6
|
klass = Class.new do
|
7
7
|
include MiniTest::Reporter
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
@reporter = klass.new
|
11
11
|
end
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
def test_callbacks
|
14
14
|
[
|
15
15
|
:before_suites, :after_suite, :before_suite, :after_suite, :before_test,
|
16
16
|
:pass, :skip, :failure, :error
|
17
17
|
].each { |method| assert_respond_to @reporter, method }
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
def test_runner
|
21
21
|
assert_kind_of MiniTest::Unit, @reporter.runner
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
|
24
|
+
def test_output
|
25
25
|
assert_equal MiniTest::Unit.output, @reporter.output
|
26
26
|
end
|
27
|
-
|
28
|
-
|
27
|
+
|
28
|
+
def test_verbose
|
29
29
|
refute @reporter.verbose?
|
30
|
-
|
30
|
+
|
31
31
|
begin
|
32
32
|
@reporter.runner.verbose = true
|
33
33
|
assert @reporter.verbose?
|
@@ -35,14 +35,14 @@ module MiniTestReportersTest
|
|
35
35
|
@reporter.runner.verbose = false
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
|
-
|
40
|
-
@reporter.output.
|
38
|
+
|
39
|
+
def test_print
|
40
|
+
mock(@reporter.output).print('foo')
|
41
41
|
@reporter.print('foo')
|
42
42
|
end
|
43
|
-
|
44
|
-
|
45
|
-
@reporter.output.
|
43
|
+
|
44
|
+
def test_puts
|
45
|
+
mock(@reporter.output).puts('foo')
|
46
46
|
@reporter.puts('foo')
|
47
47
|
end
|
48
48
|
end
|
@@ -2,10 +2,10 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module MiniTestReportersTest
|
4
4
|
class ReportersTest < TestCase
|
5
|
-
|
5
|
+
def test_chooses_the_rubymine_reporter_when_necessary
|
6
6
|
# Rubymine reporter complains when RubyMine libs are not available, so
|
7
7
|
# stub its #puts method out.
|
8
|
-
MiniTest::Unit.runner.output.
|
8
|
+
stub(MiniTest::Unit.runner.output).puts
|
9
9
|
|
10
10
|
reporters = Minitest::Reporters.choose_reporters [], { "RM_INFO" => "x" }
|
11
11
|
assert_instance_of MiniTest::Reporters::RubyMineReporter, reporters[0]
|
@@ -14,12 +14,12 @@ module MiniTestReportersTest
|
|
14
14
|
assert_instance_of MiniTest::Reporters::RubyMineReporter, reporters[0]
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
def test_chooses_the_textmate_reporter_when_necessary
|
18
18
|
reporters = Minitest::Reporters.choose_reporters [], {"TM_PID" => "x"}
|
19
19
|
assert_instance_of MiniTest::Reporters::RubyMateReporter, reporters[0]
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
def test_chooses_the_console_reporters_when_necessary
|
23
23
|
reporters = Minitest::Reporters.choose_reporters [MiniTest::Reporters::SpecReporter.new], {}
|
24
24
|
assert_instance_of MiniTest::Reporters::SpecReporter, reporters[0]
|
25
25
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,20 +1,11 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'minitest/autorun'
|
3
|
-
require '
|
4
|
-
require 'test_declarative'
|
3
|
+
require 'rr'
|
5
4
|
require 'minitest/reporters'
|
6
5
|
|
7
6
|
module MiniTestReportersTest
|
8
|
-
|
9
|
-
|
10
|
-
module Fixtures
|
11
|
-
require File.expand_path('../support/fixtures/test_case_fixture', __FILE__)
|
12
|
-
require File.expand_path('../support/fixtures/empty_test_fixture', __FILE__)
|
13
|
-
require File.expand_path('../support/fixtures/error_test_fixture', __FILE__)
|
14
|
-
require File.expand_path('../support/fixtures/failure_test_fixture', __FILE__)
|
15
|
-
require File.expand_path('../support/fixtures/pass_test_fixture', __FILE__)
|
16
|
-
require File.expand_path('../support/fixtures/skip_test_fixture', __FILE__)
|
17
|
-
require File.expand_path('../support/fixtures/suite_callback_test_fixture', __FILE__)
|
7
|
+
class TestCase < MiniTest::Unit::TestCase
|
8
|
+
include RR::Adapters::MiniTest
|
18
9
|
end
|
19
10
|
end
|
20
11
|
|
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.10.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-07-
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2.
|
21
|
+
version: '2.12'
|
22
22
|
- - <
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '4.0'
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '2.
|
32
|
+
version: '2.12'
|
33
33
|
- - <
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '4.0'
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: rr
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
none: false
|
88
88
|
requirements:
|
@@ -113,22 +113,6 @@ dependencies:
|
|
113
113
|
- - ! '>='
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
|
-
- !ruby/object:Gem::Dependency
|
117
|
-
name: test_declarative
|
118
|
-
requirement: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
|
-
requirements:
|
121
|
-
- - ! '>='
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '0'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
|
-
requirements:
|
129
|
-
- - ! '>='
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
116
|
- !ruby/object:Gem::Dependency
|
133
117
|
name: rake
|
134
118
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,7 +144,9 @@ files:
|
|
160
144
|
- README.md
|
161
145
|
- Rakefile
|
162
146
|
- lib/minitest/backtrace_filter.rb
|
147
|
+
- lib/minitest/before_test_hook.rb
|
163
148
|
- lib/minitest/reporter.rb
|
149
|
+
- lib/minitest/reporter_runner.rb
|
164
150
|
- lib/minitest/reporters.rb
|
165
151
|
- lib/minitest/reporters/default_reporter.rb
|
166
152
|
- lib/minitest/reporters/guard_reporter.rb
|
@@ -170,22 +156,11 @@ files:
|
|
170
156
|
- lib/minitest/reporters/rubymine_reporter.rb
|
171
157
|
- lib/minitest/reporters/spec_reporter.rb
|
172
158
|
- lib/minitest/reporters/version.rb
|
173
|
-
- lib/minitest/suite_runner.rb
|
174
159
|
- lib/minitest/test_runner.rb
|
175
160
|
- minitest-reporters.gemspec
|
176
161
|
- test/minitest/backtrace_filter_test.rb
|
177
162
|
- test/minitest/reporter_test.rb
|
178
163
|
- test/minitest/reporters_test.rb
|
179
|
-
- test/minitest/suite_runner_test.rb
|
180
|
-
- test/minitest/test_runner_test.rb
|
181
|
-
- test/support/fixtures/empty_test_fixture.rb
|
182
|
-
- test/support/fixtures/error_test_fixture.rb
|
183
|
-
- test/support/fixtures/failure_test_fixture.rb
|
184
|
-
- test/support/fixtures/pass_test_fixture.rb
|
185
|
-
- test/support/fixtures/skip_test_fixture.rb
|
186
|
-
- test/support/fixtures/suite_callback_test_fixture.rb
|
187
|
-
- test/support/fixtures/test_case_fixture.rb
|
188
|
-
- test/support/test_case.rb
|
189
164
|
- test/test_helper.rb
|
190
165
|
homepage: https://github.com/CapnKernul/minitest-reporters
|
191
166
|
licenses: []
|
@@ -201,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
176
|
version: '0'
|
202
177
|
segments:
|
203
178
|
- 0
|
204
|
-
hash:
|
179
|
+
hash: 3874457769361975598
|
205
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
181
|
none: false
|
207
182
|
requirements:
|
@@ -210,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
185
|
version: '0'
|
211
186
|
segments:
|
212
187
|
- 0
|
213
|
-
hash:
|
188
|
+
hash: 3874457769361975598
|
214
189
|
requirements: []
|
215
190
|
rubyforge_project: minitest-reporters
|
216
191
|
rubygems_version: 1.8.24
|
@@ -221,14 +196,4 @@ test_files:
|
|
221
196
|
- test/minitest/backtrace_filter_test.rb
|
222
197
|
- test/minitest/reporter_test.rb
|
223
198
|
- test/minitest/reporters_test.rb
|
224
|
-
- test/minitest/suite_runner_test.rb
|
225
|
-
- test/minitest/test_runner_test.rb
|
226
|
-
- test/support/fixtures/empty_test_fixture.rb
|
227
|
-
- test/support/fixtures/error_test_fixture.rb
|
228
|
-
- test/support/fixtures/failure_test_fixture.rb
|
229
|
-
- test/support/fixtures/pass_test_fixture.rb
|
230
|
-
- test/support/fixtures/skip_test_fixture.rb
|
231
|
-
- test/support/fixtures/suite_callback_test_fixture.rb
|
232
|
-
- test/support/fixtures/test_case_fixture.rb
|
233
|
-
- test/support/test_case.rb
|
234
199
|
- test/test_helper.rb
|
@@ -1,110 +0,0 @@
|
|
1
|
-
module MiniTest
|
2
|
-
# Runner for MiniTest suites.
|
3
|
-
#
|
4
|
-
# This is a heavily refactored version of the built-in MiniTest runner. It's
|
5
|
-
# about the same speed, from what I can tell, but is significantly easier to
|
6
|
-
# extend.
|
7
|
-
#
|
8
|
-
# Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
|
9
|
-
#
|
10
|
-
# @see https://github.com/seattlerb/minitest MiniTest
|
11
|
-
class SuiteRunner < Unit
|
12
|
-
attr_accessor :suite_start_time, :test_start_time, :reporters
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
self.report = {}
|
16
|
-
self.errors = 0
|
17
|
-
self.failures = 0
|
18
|
-
self.skips = 0
|
19
|
-
self.test_count = 0
|
20
|
-
self.assertion_count = 0
|
21
|
-
self.verbose = false
|
22
|
-
self.reporters = []
|
23
|
-
end
|
24
|
-
|
25
|
-
def _run_anything(type)
|
26
|
-
self.start_time = Time.now
|
27
|
-
|
28
|
-
suites = suites_of_type(type)
|
29
|
-
tests = suites.inject({}) do |acc, suite|
|
30
|
-
acc[suite] = filtered_tests(suite, type)
|
31
|
-
acc
|
32
|
-
end
|
33
|
-
|
34
|
-
self.test_count = tests.inject(0) { |acc, suite| acc + suite[1].length }
|
35
|
-
|
36
|
-
if test_count > 0
|
37
|
-
trigger(:before_suites, suites, type)
|
38
|
-
|
39
|
-
fix_sync do
|
40
|
-
suites.each { |suite| _run_suite(suite, tests[suite]) }
|
41
|
-
end
|
42
|
-
|
43
|
-
trigger(:after_suites, suites, type)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def _run_suite(suite, tests)
|
48
|
-
unless tests.empty?
|
49
|
-
begin
|
50
|
-
self.suite_start_time = Time.now
|
51
|
-
|
52
|
-
trigger(:before_suite, suite)
|
53
|
-
suite.startup if suite.respond_to?(:startup)
|
54
|
-
|
55
|
-
tests.each { |test| _run_test(suite, test) }
|
56
|
-
ensure
|
57
|
-
suite.shutdown if suite.respond_to?(:shutdown)
|
58
|
-
trigger(:after_suite, suite)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def _run_test(suite, test)
|
64
|
-
self.test_start_time = Time.now
|
65
|
-
trigger(:before_test, suite, test)
|
66
|
-
|
67
|
-
test_runner = TestRunner.new(suite, test)
|
68
|
-
test_runner.run
|
69
|
-
add_test_result(suite, test, test_runner)
|
70
|
-
|
71
|
-
trigger(test_runner.result, suite, test, test_runner)
|
72
|
-
end
|
73
|
-
|
74
|
-
def trigger(callback, *args)
|
75
|
-
reporters.each { |reporter| reporter.send(callback, *args) }
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def filtered_tests(suite, type)
|
81
|
-
filter = options[:filter] || '/./'
|
82
|
-
filter = Regexp.new($1) if filter =~ /\/(.*)\//
|
83
|
-
suite.send("#{type}_methods").grep(filter)
|
84
|
-
end
|
85
|
-
|
86
|
-
def suites_of_type(type)
|
87
|
-
TestCase.send("#{type}_suites")
|
88
|
-
end
|
89
|
-
|
90
|
-
def add_test_result(suite, test, test_runner)
|
91
|
-
self.report[suite] ||= {}
|
92
|
-
self.report[suite][test.to_sym] = test_runner
|
93
|
-
|
94
|
-
self.assertion_count += test_runner.assertions
|
95
|
-
|
96
|
-
case test_runner.result
|
97
|
-
when :skip then self.skips += 1
|
98
|
-
when :failure then self.failures += 1
|
99
|
-
when :error then self.errors += 1
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def fix_sync
|
104
|
-
sync = output.respond_to?(:'sync=') # stupid emacs
|
105
|
-
old_sync, output.sync = output.sync, true if sync
|
106
|
-
yield
|
107
|
-
output.sync = old_sync if sync
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,164 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module MiniTestReportersTest
|
4
|
-
class SuiteRunnerTest < TestCase
|
5
|
-
def setup
|
6
|
-
@runner = MiniTest::SuiteRunner.new
|
7
|
-
@reporter = add_reporter
|
8
|
-
end
|
9
|
-
|
10
|
-
test '#report' do
|
11
|
-
assert_equal({}, @runner.report)
|
12
|
-
end
|
13
|
-
|
14
|
-
test '#reporters' do
|
15
|
-
assert_equal [@reporter], @runner.reporters
|
16
|
-
|
17
|
-
reporter2 = add_reporter
|
18
|
-
assert_equal [@reporter, reporter2], @runner.reporters
|
19
|
-
end
|
20
|
-
|
21
|
-
test '#_run_anything with no suites' do
|
22
|
-
stub_suites([])
|
23
|
-
|
24
|
-
@reporter.expects(:before_suites).never
|
25
|
-
@reporter.expects(:after_suites).never
|
26
|
-
|
27
|
-
@runner._run_anything(:test)
|
28
|
-
|
29
|
-
assert_equal 0, @runner.test_count
|
30
|
-
assert_equal 0, @runner.assertion_count
|
31
|
-
assert_instance_of Time, @runner.start_time
|
32
|
-
assert_equal({}, @runner.report)
|
33
|
-
end
|
34
|
-
|
35
|
-
test '#_run_anything with suites' do
|
36
|
-
suites = [Fixtures::PassTestFixture, Fixtures::SkipTestFixture]
|
37
|
-
stub_suites(suites)
|
38
|
-
|
39
|
-
@reporter.expects(:before_suites).with(suites, :test)
|
40
|
-
@reporter.expects(:after_suites).with(suites, :test)
|
41
|
-
|
42
|
-
@runner._run_anything(:test)
|
43
|
-
|
44
|
-
assert_equal 3, @runner.test_count
|
45
|
-
assert_equal 3, @runner.assertion_count
|
46
|
-
assert_instance_of Time, @runner.start_time
|
47
|
-
assert_equal :pass, @runner.report[Fixtures::PassTestFixture][:test_pass].result
|
48
|
-
assert_equal :pass, @runner.report[Fixtures::PassTestFixture][:test_foo].result
|
49
|
-
assert_equal :skip, @runner.report[Fixtures::SkipTestFixture][:test_skip].result
|
50
|
-
end
|
51
|
-
|
52
|
-
test '#_run_anything with a filter' do
|
53
|
-
@runner.options[:filter] = '/foo/'
|
54
|
-
stub_suites([Fixtures::PassTestFixture])
|
55
|
-
|
56
|
-
@runner._run_anything(:test)
|
57
|
-
assert_equal 2, @runner.assertion_count
|
58
|
-
end
|
59
|
-
|
60
|
-
test '#_run_suite without tests' do
|
61
|
-
@reporter.expects(:before_suite).never
|
62
|
-
@reporter.expects(:after_suite).never
|
63
|
-
|
64
|
-
@runner._run_suite(Fixtures::EmptyTestFixture, [])
|
65
|
-
end
|
66
|
-
|
67
|
-
test '#_run_suite with tests' do
|
68
|
-
@reporter.expects(:before_suite).with(Fixtures::PassTestFixture)
|
69
|
-
@reporter.expects(:after_suite).with(Fixtures::PassTestFixture)
|
70
|
-
|
71
|
-
@runner._run_suite(Fixtures::PassTestFixture, [:test_pass, :test_foo])
|
72
|
-
|
73
|
-
assert_equal 3, @runner.assertion_count
|
74
|
-
assert_instance_of Time, @runner.suite_start_time
|
75
|
-
end
|
76
|
-
|
77
|
-
test '#_run_suite with a suite .startup and .shutdown' do
|
78
|
-
suite = Fixtures::SuiteCallbackTestFixture
|
79
|
-
suite.expects(:startup)
|
80
|
-
suite.expects(:shutdown)
|
81
|
-
@runner._run_suite(suite, [:test_foo])
|
82
|
-
end
|
83
|
-
|
84
|
-
test '#_run_test with a passing test' do
|
85
|
-
suite = Fixtures::PassTestFixture
|
86
|
-
test = :test_pass
|
87
|
-
|
88
|
-
@reporter.expects(:before_test).with(suite, test)
|
89
|
-
@reporter.expects(:pass).with(suite, test, instance_of(MiniTest::TestRunner))
|
90
|
-
|
91
|
-
@runner._run_test(suite, test)
|
92
|
-
|
93
|
-
assert_equal 1, @runner.assertion_count
|
94
|
-
assert_instance_of Time, @runner.test_start_time
|
95
|
-
assert_equal :pass, @runner.report[suite][test].result
|
96
|
-
end
|
97
|
-
|
98
|
-
test '#_run_test with a skipped test' do
|
99
|
-
suite = Fixtures::SkipTestFixture
|
100
|
-
test = :test_skip
|
101
|
-
|
102
|
-
@reporter.expects(:before_test).with(suite, test)
|
103
|
-
@reporter.expects(:skip).with(suite, test, instance_of(MiniTest::TestRunner))
|
104
|
-
|
105
|
-
@runner._run_test(suite, test)
|
106
|
-
|
107
|
-
assert_equal 0, @runner.assertion_count
|
108
|
-
assert_instance_of Time, @runner.test_start_time
|
109
|
-
assert_equal :skip, @runner.report[suite][test].result
|
110
|
-
end
|
111
|
-
|
112
|
-
test '#_run_test with a failing test' do
|
113
|
-
suite = Fixtures::FailureTestFixture
|
114
|
-
test = :test_failure
|
115
|
-
|
116
|
-
@reporter.expects(:before_test).with(suite, test)
|
117
|
-
@reporter.expects(:failure).with(suite, test, instance_of(MiniTest::TestRunner))
|
118
|
-
|
119
|
-
@runner._run_test(suite, test)
|
120
|
-
|
121
|
-
assert_equal 0, @runner.assertion_count
|
122
|
-
assert_instance_of Time, @runner.test_start_time
|
123
|
-
assert_equal :failure, @runner.report[suite][test].result
|
124
|
-
end
|
125
|
-
|
126
|
-
test '#_run_test with an error test' do
|
127
|
-
suite = Fixtures::ErrorTestFixture
|
128
|
-
test = :test_error
|
129
|
-
|
130
|
-
@reporter.expects(:before_test).with(suite, test)
|
131
|
-
@reporter.expects(:error).with(suite, test, instance_of(MiniTest::TestRunner))
|
132
|
-
|
133
|
-
@runner._run_test(suite, test)
|
134
|
-
|
135
|
-
assert_equal 0, @runner.assertion_count
|
136
|
-
assert_instance_of Time, @runner.test_start_time
|
137
|
-
assert_equal :error, @runner.report[suite][test].result
|
138
|
-
end
|
139
|
-
|
140
|
-
test '#trigger' do
|
141
|
-
reporter2 = add_reporter
|
142
|
-
@reporter.expects(:before_suite).with(Fixtures::PassTestFixture)
|
143
|
-
reporter2.expects(:before_suite).with(Fixtures::PassTestFixture)
|
144
|
-
|
145
|
-
@runner.trigger(:before_suite, Fixtures::PassTestFixture)
|
146
|
-
end
|
147
|
-
|
148
|
-
private
|
149
|
-
|
150
|
-
def add_reporter
|
151
|
-
klass = Class.new do
|
152
|
-
include MiniTest::Reporter
|
153
|
-
end
|
154
|
-
|
155
|
-
reporter = klass.new
|
156
|
-
@runner.reporters << reporter
|
157
|
-
reporter
|
158
|
-
end
|
159
|
-
|
160
|
-
def stub_suites(suites)
|
161
|
-
MiniTest::Unit::TestCase.stubs(:test_suites).returns(suites)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module MiniTestReportersTest
|
4
|
-
class TestRunnerTest < TestCase
|
5
|
-
def setup
|
6
|
-
@suite = stub
|
7
|
-
@test = :test_foo
|
8
|
-
@runner = MiniTest::TestRunner.new(@suite, @test)
|
9
|
-
end
|
10
|
-
|
11
|
-
test '#suite' do
|
12
|
-
assert_equal @suite, @runner.suite
|
13
|
-
end
|
14
|
-
|
15
|
-
test '#test' do
|
16
|
-
assert_equal @test, @runner.test
|
17
|
-
end
|
18
|
-
|
19
|
-
test '#run with a passing test' do
|
20
|
-
suite_instance = stub(:_assertions => 3)
|
21
|
-
suite_instance.expects(:run).with(@runner).returns('.')
|
22
|
-
@suite.stubs(:new).with(@test).returns(suite_instance)
|
23
|
-
|
24
|
-
@runner.run
|
25
|
-
|
26
|
-
assert_equal :pass, @runner.result
|
27
|
-
assert_nil @runner.exception
|
28
|
-
assert_equal 3, @runner.assertions
|
29
|
-
end
|
30
|
-
|
31
|
-
test '#run with an skipped test' do
|
32
|
-
error = stub
|
33
|
-
suite_instance = stub(:_assertions => 3)
|
34
|
-
suite_instance.expects(:run).with(@runner).returns([:skip, error])
|
35
|
-
@suite.stubs(:new).with(@test).returns(suite_instance)
|
36
|
-
|
37
|
-
@runner.run
|
38
|
-
|
39
|
-
assert_equal :skip, @runner.result
|
40
|
-
assert_equal error, @runner.exception
|
41
|
-
assert_equal 3, @runner.assertions
|
42
|
-
end
|
43
|
-
|
44
|
-
test '#run with a failing test' do
|
45
|
-
error = stub
|
46
|
-
suite_instance = stub(:_assertions => 3)
|
47
|
-
suite_instance.expects(:run).with(@runner).returns([:failure, error])
|
48
|
-
@suite.stubs(:new).with(@test).returns(suite_instance)
|
49
|
-
|
50
|
-
@runner.run
|
51
|
-
|
52
|
-
assert_equal :failure, @runner.result
|
53
|
-
assert_equal error, @runner.exception
|
54
|
-
assert_equal 3, @runner.assertions
|
55
|
-
end
|
56
|
-
|
57
|
-
test '#run with an errored test' do
|
58
|
-
error = stub
|
59
|
-
suite_instance = stub(:_assertions => 3)
|
60
|
-
suite_instance.expects(:run).with(@runner).returns([:error, error])
|
61
|
-
@suite.stubs(:new).with(@test).returns(suite_instance)
|
62
|
-
|
63
|
-
@runner.run
|
64
|
-
|
65
|
-
assert_equal :error, @runner.result
|
66
|
-
assert_equal error, @runner.exception
|
67
|
-
assert_equal 3, @runner.assertions
|
68
|
-
end
|
69
|
-
|
70
|
-
test '#puke with a skip' do
|
71
|
-
skip = MiniTest::Skip.new
|
72
|
-
result = @runner.puke(@suite, @test, skip)
|
73
|
-
|
74
|
-
assert_equal [:skip, skip], result
|
75
|
-
end
|
76
|
-
|
77
|
-
test '#puke with a failure' do
|
78
|
-
failure = MiniTest::Assertion.new
|
79
|
-
result = @runner.puke(@suite, @test, failure)
|
80
|
-
|
81
|
-
assert_equal [:failure, failure], result
|
82
|
-
end
|
83
|
-
|
84
|
-
test '#puke with an error' do
|
85
|
-
error = RuntimeError.new
|
86
|
-
result = @runner.puke(@suite, @test, error)
|
87
|
-
|
88
|
-
assert_equal [:error, error], result
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module MiniTestReportersTest
|
2
|
-
module Fixtures
|
3
|
-
class TestCaseFixture
|
4
|
-
attr_writer :_assertions
|
5
|
-
|
6
|
-
def self.test_methods
|
7
|
-
public_instance_methods(true).grep(/^test/)
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(test)
|
11
|
-
@test = test
|
12
|
-
end
|
13
|
-
|
14
|
-
def run(runner)
|
15
|
-
send(@test)
|
16
|
-
'.'
|
17
|
-
rescue MiniTest::Assertion, RuntimeError => e
|
18
|
-
runner.puke(self, @test, e)
|
19
|
-
end
|
20
|
-
|
21
|
-
def skip
|
22
|
-
raise MiniTest::Skip.new
|
23
|
-
end
|
24
|
-
|
25
|
-
def flunk
|
26
|
-
raise MiniTest::Assertion.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def assert(value)
|
30
|
-
self._assertions += 1
|
31
|
-
end
|
32
|
-
|
33
|
-
def _assertions
|
34
|
-
@_assertions ||= 0
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/test/support/test_case.rb
DELETED