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(backtrace_filter = MiniTest::BacktraceFilter.default_filter) ⇒ 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
#initialize(backtrace_filter = MiniTest::BacktraceFilter.default_filter) ⇒ ProgressReporter
Returns a new instance of ProgressReporter.
19
20
21
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 19
def initialize(backtrace_filter = MiniTest::BacktraceFilter.default_filter)
@backtrace_filter = backtrace_filter
end
|
Instance Method Details
#after_suites(suites, type)
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 74
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)
23
24
25
26
27
28
29
30
31
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 23
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)
64
65
66
67
68
69
70
71
72
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 64
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)
54
55
56
57
58
59
60
61
62
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 54
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
33
34
35
36
37
38
39
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 33
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)
41
42
43
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 41
def pass(suite, test, test_runner)
increment
end
|
#skip(suite, test, test_runner)
45
46
47
48
49
50
51
52
|
# File 'lib/minitest/reporters/progress_reporter.rb', line 45
def skip(suite, test, test_runner)
@color = YELLOW unless @color == RED
print(yellow { 'SKIP' })
print_test_with_time(suite, test)
puts
puts
increment
end
|