We are developing an application on Ruby 1.9.3 and Rails 3.2.1.
Our unit tests have recently become sluggish at the start. It takes ~ 15 seconds to complete calls and executions. As soon as I see "Execute test: units", it takes another 10 seconds before I see any output. Finally, the task is completed and the tests are completed in only 3 seconds.
3 seconds for unit tests is acceptable. A boot time of 25 seconds is unrealistic for BDD / TDD.
This is what happens when I run with rake test:units --trace
:
** Invoke test:units (first_time) ** Invoke test:prepare (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:load ** Invoke db:test:load_schema (first_time) ** Invoke db:test:purge ** Execute db:test:load_schema ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load ** Execute test:prepare ** Execute test:units
I have no doubt that a loadable, then reloaded database schema will become a key source of slowness. However, I did nothing for our Rakefile
related to unit tests. Where can I look to see what is really happening under the hood?
This is what is at the top of test/test_helper.rb
:
require 'simplecov' ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help'
What I tried:
- Commenting on
simplecov
, since we use this only for our CI server, and not at development time (it does not matter at run time) - Comment on other material, but it broke the tests even from execution. I'm not quite sure why these other elements exist, since I thought the Rails framework would be loaded into the βtestβ automatically.
Any ideas on where / how I can poke my head to see?
Is there any chance that Rails triggers a migration, not just schema:load
? As we develop, we have a large number of migrations (~ 30).
EDIT:
I am using the 2011 Macbook Pro with 8G RAM and Core i7 - I donβt think this is my car. I saw in this question that on Windows require
can cause problems.
I also thought that problems could be a problem, but if the problem was related to errors, the tests themselves, and not the load time of the tests, would be slow, right?
EDIT 2:
Thanks to pchap10k's answer, I think this has nothing to do with the rake - this is about our Gemfile
. Maybe I should search in this area ...