Permalink
Browse files

Print slowest tests if options[:output_slow]

  • Loading branch information...
1 parent f72c94e commit 05682eb39835794906be9fb66a2cebaa24889841 @quirkey committed Aug 2, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/minitest/display.rb
View
9 lib/minitest/display.rb
@@ -28,6 +28,7 @@ def options
suite_time: true,
color: true,
wrap_at: 80,
+ output_slow: 5,
print: {
success: '.',
failure: 'F',
@@ -215,6 +216,14 @@ def status(io = self.output)
format = "%d tests, %d assertions, %d failures, %d errors, %d skips"
final_status = failures + errors > 0 ? :failure : :success
io.puts display.color(format % [test_count, assertion_count, failures, errors, skips], [:bold, final_status])
+
+ if display.options[:output_slow]
+ @test_times.sort! {|a, b| b[1] <=> a[1] }
+ puts "Slowest tests:"
+ @test_times[0..display.options[:output_slow].to_i].each do |test_name, time|
+ puts "%.2f s\t#{test_name}" % time
+ end
+ end
end
private

0 comments on commit 05682eb

Please sign in to comment.