9167064d701696b63bbb819595a6e5ca
Jul 16, 2012

Have you ever felt like running more than one kind of test at the same time, because your tests take so long or just to earn some extra free time? I looked for a solution to this problem, and I actually found a good one.

The gem is called parallel_test, and, it give us the functionality and the possibility to run in parallel:

  • Unit tests
  • Spec tests
  • Feature tests

You could run the multiple combinations of these as well at the same time and sharing the same test database.

The speed applied to these parallel tests is relative to the hardware in your device, so if you have the latest generation of microprocessors, you should feel a huge difference on performance while running your tests.

Setup for Rails

Install

# add to Gemfile
gem "parallel_tests", :group => :development

Setup

1.- Add to your config/database.yml

test:
database: your_project_test<%= ENV['TEST_ENV_NUMBER']%>

2.- Create additional database(s)

rake parallel:create

3.- Copy the development schema (repeat after migrations)

rake parallel:prepare

4.- Run!

rake parallel:test          # Test::Unit
rake parallel:spec          # RSpec
rake parallel:features      # Cucumber

rake parallel:test[1] # force 1 CPU --> 86 seconds rake parallel:test # got 2 CPUs? --> 47 seconds rake parallel:test # got 4 CPUs? --> 26 seconds ...

There's a lot more custom options to this gem, you can read all about it here: https://github.com/grosser/parallel_tests

blog comments powered byDisqus

About Crowd Interactive

Crowd Interactive is a leading Ruby and Rails consultancy firm based in Mexico currently doing business with startups in the United States.

We specialize in building and growing Rails applications, by increasing your IT crew onsite or offsite. We pick our projects carefully, as we only work with companies we believe in.

You can find out more about us on our website.

Our Favorite Sites

Our conference

Conferences we attend

Stuff we've built

Earlier Posts