class Minitest::Reporters::ProgressReporter
Fuubar-like reporter with a progress bar.
Based upon Jeff Kreefmeijer's Fuubar (MIT License) and paydro's monkey-patch.
@see github.com/jeffkreeftmeijer/fuubar Fuubar @see gist.github.com/356945 paydro's monkey-patch
Constants
- PROGRESS_MARK
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
Minitest::Reporters::BaseReporter::new
# File lib/minitest/reporters/progress_reporter.rb, line 18 def initialize(options = {}) super @detailed_skip = options.fetch(:detailed_skip, true) @progress = ProgressBar.create({ total: total_count, starting_at: count, progress_mark: green(PROGRESS_MARK), remainder_mark: ' ', format: ' %C/%c: [%B] %p%% %a, %e', autostart: false }) end
Public Instance Methods
record(test)
click to toggle source
Calls superclass method
Minitest::Reporters::BaseReporter#record
# File lib/minitest/reporters/progress_reporter.rb, line 41 def record(test) super return if test.skipped? && !@detailed_skip if test.failure print "\e[0m\e[1000D\e[K" print_colored_status(test) print_test_with_time(test) puts print_info(test.failure, test.error?) puts end if test.skipped? && color != "red" self.color = "yellow" elsif test.failure self.color = "red" end show end
report()
click to toggle source
Calls superclass method
Minitest::Reporters::BaseReporter#report
# File lib/minitest/reporters/progress_reporter.rb, line 62 def report super @progress.finish puts puts('Finished in %.5fs' % total_time) print('%d tests, %d assertions, ' % [count, assertions]) color = failures.zero? && errors.zero? ? :green : :red print(send(color) { '%d failures, %d errors, ' } % [failures, errors]) print(yellow { '%d skips' } % skips) puts end
start()
click to toggle source
Calls superclass method
# File lib/minitest/reporters/progress_reporter.rb, line 32 def start super puts('Started with run options %s' % options[:args]) puts @progress.start @progress.total = total_count show end
Private Instance Methods
color()
click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 86 def color @color ||= "green" end
color=(color)
click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 90 def color=(color) @color = color @progress.progress_mark = send(color, PROGRESS_MARK) end
print_test_with_time(test)
click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 81 def print_test_with_time(test) puts [test.name, test.class, total_time].inspect print(" %s#%s (%.2fs)" % [test.name, test.class, total_time]) end
show()
click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 77 def show @progress.increment unless count == 0 end