Skip to content

Instantly share code, notes, and snippets.

@cadwallion
Created September 9, 2011 14:05
Show Gist options
  • Save cadwallion/1206308 to your computer and use it in GitHub Desktop.
Save cadwallion/1206308 to your computer and use it in GitHub Desktop.
Adds timing to ActiveSupport::TestCase
# snip
Spork.prefork do
#snip
class ActiveSupport::TestCase
setup :mark_test_start_time
teardown :record_test_duration
def mark_test_start_time
@start_time = Time.now
end
def record_test_duration
File.open("#{Rails.root}/tmp/test_metrics.csv", "a") do |file|
file.puts "#{self.class},#{method_name.gsub(/,/, '_')},#{Time.now - @start_time}"
end
end
end
# snip
end
# snip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment