Skip to content

Instantly share code, notes, and snippets.

@rsl
Forked from danabr/test_helper.rb
Created July 24, 2013 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsl/6071807 to your computer and use it in GitHub Desktop.
Save rsl/6071807 to your computer and use it in GitHub Desktop.
class Test::Unit::TestCase # Or ActiveSupport::TestCase if you are using Rails
# This is a debugging utility to find slow tests.
# Usage: rake FIND_SLOW_TESTS=true test:units
unless ENV["FIND_SLOW_TESTS"].blank?
alias_method :old_run, :run
def run(*args, &block)
start_time = Time.now
old_run *args, &block
test_time = Time.now - start_time
puts "\nSLOW TEST: #{self.name}, #{test_time}s" if test_time > 0.5
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment