Created
September 9, 2011 14:05
-
-
Save cadwallion/1206308 to your computer and use it in GitHub Desktop.
Adds timing to ActiveSupport::TestCase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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