Skip to content

Instantly share code, notes, and snippets.

View danabr's full-sized avatar

Daniel Abrahamsson danabr

View GitHub Profile
@danabr
danabr / test_helper.rb
Created April 30, 2011 13:37
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