Skip to content

Instantly share code, notes, and snippets.

@danabr
Created April 30, 2011 13:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danabr/949673 to your computer and use it in GitHub Desktop.
Save danabr/949673 to your computer and use it in GitHub Desktop.
Find slow test cases in Test::Unit
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