Class: MiniTest::Reporters::ProgressReporter
- Inherits:
-
Object
- Object
- MiniTest::Reporters::ProgressReporter
show all
- Includes:
- ANSI::Code, MiniTest::Reporter
- Defined in:
- lib/minitest/reporters/progress_reporter.rb
Overview
Fuubar-like reporter with a progress bar.
Based upon Jeff Kreefmeijer's Fuubar (MIT License) and paydro's
monkey-patch.
Constant Summary
collapse
- INFO_PADDING =
2
Instance Method Summary
collapse
-
#after_suites(suites, type)
-
#before_suites(suites, type)
-
#error(suite, test, test_runner)
-
#failure(suite, test, test_runner)
-
#increment
-
#initialize(options = {}) ⇒ ProgressReporter
constructor
A new instance of ProgressReporter.
-
#pass(suite, test, test_runner)
-
#skip(suite, test, test_runner)
#after_suite, #before_suite, #before_test, #output, #print, #puts, #runner, #verbose?
Constructor Details
Returns a new instance of ProgressReporter.
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 19
def initialize(options = {})
if options.is_a?(Hash)
@backtrace_filter = options.fetch(:backtrace_filter, BacktraceFilter.default_filter)
@detailed_skip = options.fetch(:detailed_skip, true)
else
warn "Please use :backtrace_filter => filter instead of passing in the filter directly."
@backtrace_filter = options
@detailed_skip = true
end
end
|
Instance Method Details
#after_suites(suites, type)
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 85
def after_suites(suites, type)
with_color { @progress.finish }
total_time = Time.now - runner.start_time
puts
puts('Finished in %.5fs' % total_time)
print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
print(red { '%d failures, %d errors, ' } % [runner.failures, runner.errors])
print(yellow { '%d skips' } % runner.skips)
puts
end
|
#before_suites(suites, type)
30
31
32
33
34
35
36
37
38
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 30
def before_suites(suites, type)
puts 'Started'
puts
@color = GREEN
@finished_count = 0
@progress = ProgressBar.new("0/#{runner.test_count}", runner.test_count, runner.output)
@progress.bar_mark = '='
end
|
#error(suite, test, test_runner)
75
76
77
78
79
80
81
82
83
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 75
def error(suite, test, test_runner)
@color = RED
print(red { 'ERROR' })
print_test_with_time(suite, test)
puts
print_info(test_runner.exception)
puts
increment
end
|
#failure(suite, test, test_runner)
65
66
67
68
69
70
71
72
73
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 65
def failure(suite, test, test_runner)
@color = RED
print(red { 'FAIL' })
print_test_with_time(suite, test)
puts
print_info(test_runner.exception)
puts
increment
end
|
#increment
40
41
42
43
44
45
46
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 40
def increment
with_color do
@finished_count += 1
@progress.instance_variable_set('@title', "#{@finished_count}/#{runner.test_count}")
@progress.inc
end
end
|
#pass(suite, test, test_runner)
48
49
50
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 48
def pass(suite, test, test_runner)
increment
end
|
#skip(suite, test, test_runner)
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 52
def skip(suite, test, test_runner)
@color = YELLOW unless @color == RED
if @detailed_skip
print(yellow { 'SKIP' })
print_test_with_time(suite, test)
puts
puts
end
increment
end
|