Class: MiniTest::Reporters::DefaultReporter
Overview
A reporter identical to the standard MiniTest reporter except with more
colors.
Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
Constant Summary
MiniTest::RelativePosition::INFO_PADDING, MiniTest::RelativePosition::MARK_SIZE, MiniTest::RelativePosition::TEST_PADDING, MiniTest::RelativePosition::TEST_SIZE
Instance Method Summary
collapse
-
#after_suite(suite)
-
#after_suites(suites, type)
-
#before_suites(suites, type)
-
#before_test(suite, test)
-
#error(suite, test, test_runner)
-
#failure(suite, test, test_runner)
-
#initialize(options = {}) ⇒ DefaultReporter
constructor
A new instance of DefaultReporter.
-
#pass(suite, test, test_runner)
-
#skip(suite, test, test_runner)
#after_test, #before_suite, #filter_backtrace, #output, #print, #puts, #runner, #verbose?
Constructor Details
Returns a new instance of DefaultReporter.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/minitest/reporters/default_reporter.rb', line 15
def initialize(options = {})
@detailed_skip = options.fetch(:detailed_skip, true)
@slow_count = options.fetch(:slow_count, 0)
@slow_suite_count = options.fetch(:slow_suite_count, 0)
@fast_fail = options.fetch(:fast_fail, false)
@test_times = []
@suite_times = []
@color = options.fetch(:color) do
output.tty? && (
ENV["TERM"] =~ /^screen|color/ ||
ENV["EMACS"] == "t"
)
end
end
|
Instance Method Details
#after_suite(suite)
75
76
77
78
|
# File 'lib/minitest/reporters/default_reporter.rb', line 75
def after_suite(suite)
time = Time.now - runner.suite_start_time
@suite_times << [suite.name, time]
end
|
#after_suites(suites, type)
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/minitest/reporters/default_reporter.rb', line 80
def after_suites(suites, type)
time = Time.now - runner.suites_start_time
status_line = "Finished %ss in %.6fs, %.4f tests/s, %.4f assertions/s." %
[type, time, runner.test_count / time, runner.assertion_count / time]
puts
puts
puts colored_for(suite_result, status_line)
unless @fast_fail
runner.test_results.each do |suite, tests|
tests.each do |test, test_runner|
if message = message_for(test_runner)
puts
print colored_for(test_runner.result, message)
end
end
end
end
if @slow_count > 0
slow_tests = @test_times.sort_by { |x| x[1] }.reverse.take(@slow_count)
puts
puts "Slowest tests:"
puts
slow_tests.each do |slow_test|
puts "%.6fs %s" % [slow_test[1], slow_test[0]]
end
end
if @slow_suite_count > 0
slow_suites = @suite_times.sort_by { |x| x[1] }.reverse.take(@slow_suite_count)
puts
puts "Slowest test classes:"
puts
slow_suites.each do |slow_suite|
puts "%.6fs %s" % [slow_suite[1], slow_suite[0]]
end
end
puts
print colored_for(suite_result, result_line)
end
|
#before_suites(suites, type)
30
31
32
33
34
|
# File 'lib/minitest/reporters/default_reporter.rb', line 30
def before_suites(suites, type)
puts
puts "# Running #{type}s:"
puts
end
|
#before_test(suite, test)
36
37
38
39
|
# File 'lib/minitest/reporters/default_reporter.rb', line 36
def before_test(suite, test)
@test_name = "#{suite}##{test}"
print "#{@test_name} = " if verbose?
end
|
#error(suite, test, test_runner)
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/minitest/reporters/default_reporter.rb', line 62
def error(suite, test, test_runner)
if @fast_fail
puts
puts suite.name
print pad_test(test)
print(red(pad_mark('ERROR')))
puts
print_info(test_runner.exception)
else
test_result(red('E'))
end
end
|
#failure(suite, test, test_runner)
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/minitest/reporters/default_reporter.rb', line 49
def failure(suite, test, test_runner)
if @fast_fail
puts
puts suite.name
print pad_test(test)
print(red(pad_mark('FAIL')))
puts
print_info(test_runner.exception, false)
else
test_result(red('F'))
end
end
|
#pass(suite, test, test_runner)
41
42
43
|
# File 'lib/minitest/reporters/default_reporter.rb', line 41
def pass(suite, test, test_runner)
test_result(green('.'))
end
|
#skip(suite, test, test_runner)
45
46
47
|
# File 'lib/minitest/reporters/default_reporter.rb', line 45
def skip(suite, test, test_runner)
test_result(yellow('S'))
end
|