Created
September 8, 2014 09:06
-
-
Save jmgarnier/0573eb9fadaf6027c3c1 to your computer and use it in GitHub Desktop.
Use FactoryGirl AR instrumentation to track how much time is spent creating test data
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
# https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#activesupport-instrumentation | |
RSpec.configure do |config| | |
test_data_setup_time = 0 | |
ActiveSupport::Notifications.subscribe("factory_girl.run_factory") do |name, start, finish, id, payload| | |
execution_time_in_seconds = finish - start | |
test_data_setup_time += execution_time_in_seconds | |
if execution_time_in_seconds >= 1 | |
$stderr.puts "Slow factory: #{payload[:name]} using strategy #{payload[:strategy]}" | |
end | |
end | |
config.after(:suite) do | |
puts "Time spent creating test data: #{test_data_setup_time} seconds" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment