Skip to content
a search-and-replace job on
Pull request Compare This branch is 1 commit ahead, 2 commits behind jasonm:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Rake tasks to run tests in parallel, to use multiple CPUs and speedup test runtime.

Based heavily on on; i.e. this is a copy of parallel_spec with a handful of changes to run test/*/_test.rb instead of specs.


script/plugin install git://

Copy your test environment inside config/database.yml once for every cpu you got ('test'+number).

  adapter: mysql
  database: xxx_test
  username: root

  adapter: mysql
  database: xxx_test2
  username: root

For each environment, create the databases mysql -u root -> create database xxx_test2;

Run like hell :D

(Make sure your `test/test_helper.rb` does not set `ENV['RAILS_ENV']` to 'test')

rake test:parallel:prepare[2] #db:reset for each env

rake test:parallel[1] --> 86 seconds
rake test:parallel    --> 47 seconds (default = 2)
rake test:parallel[4] --> 26 seconds

Example output

running tests in 2 processes
93 tests per process
starting process 1
starting process 2
... test output ...
Took 47.319378 seconds


  • find out how many CPUs the user has
  • sync the output, so that results do not appear all at once
  • grab the 'xxx examples ..' line and display them at the bottom
  • find a less hacky approach (without manual creation so many envs)


inspired by pivotal labs
Michael Grosser
Hereby placed under public domain, do what you want, just do not hold me accountable...

Something went wrong with that request. Please try again.