Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Turbocharge Your Ruby Testing with Parallel Specs

By Peter Cooper / July 28, 2009

bearonshark.pngIn Make Your Test Suite UNCOMFORTABLY FAST! (called "the best blog post ever written" by one commenter) Jason Morrison of Thoughtbot demonstrates how to use Michael Grosser's Parallel Specs project to speed up your Ruby tests.

Parallel Specs provides a set of Rake tasks to run specs and tests in parallel, therefore using multiple CPUs (or cores) to multiply your testing power. It does not yet work with Cucumber features but Jason recommends testjour for that purpose - which is designed to work across multiple machines so isn't quite the same thing.

Thoughtbot has found Parallel Specs typically provides a 30-40% speedup for their projects out of the box, so if you're doing a lot of testing (and the best developers seem to say you should be) check it out for some instant satisfaction.

devver-icon.gifAlso.. Got a slow Test::Unit or RSpec suite? Run them up to three times faster on Devver's cloud! Setup is simple and requires no code changes. Request a beta invite today!


  1. Hampton Catlin says:


    The best developers don't need to test.

    You test when you hire B level drone-workers under you.


    Testing is not an excuse for under-paid, under-trained workers.

  2. Dan Manges says:

    There's also DeepTest:

    It works with test/unit and RSpec. In addition to running tests in parallel to take advantage of multiple cores, it can run tests distributed to multiple computers.

  3. peter says:

    @Hampton Catlin: Never heard something of TDD and BDD ?! Thats the hot shit now..
    no but really,my opinion is that testing should to help developing,cucumber for instance is great to integrate the user while development..but I also don't overestimate it and don't see it as the holy grail of all

  4. seydar says:

    It looks like it's only good (out-of-the-box, at least) for Rails projects. Am I wrong?

  5. yannski says:

    @Hampton : you're right, good developpers don't ever use eXtreme Programming. They use Bugless Programming. Why add bugs in your software when it will cost so much time afterwards ?!

  6. alp says:

    @Hampton:You are bullshit.

    Do you ever work for a customer? I doubt that.
    Can you imagine that requesites change while development? If that happens you can not simply change or add a feature without automated tests..sure if you're doing simple apps for you family and friends to show how smart you are then you don't need any technics to avoid mistakes.

    But if you have a business then it's interesting how you can handle systems with uncountable LOC without changing behaviour at the other end.
    But forgive me _I_ forgot that you know your software..right. You are the only one who will ever read your code..sure.
    It's written in stone,that have to be the ultimate truth and will never ever change..sure,sure.

    You are that bitch who's putting the shit together and I'am that guy who have to fix it because it never runs like it should.
    You use global flags and call it a switch-framework. You are the bitch who I have to convience to use classes,use attributes and not create temporary variables,or to use inheritance to avoid unnecassary control structures.

    Sit down and study your odds instead of generalizing everything what you don't understand, kido !

  7. Trans says:

    I'm I right in thinking this is heart of the parallel processing?

    def execute_command(cmd)
    f = open("|#{cmd}")
    all = ''
    while out = f.gets(".")#split by '.' because every test is a '.'
    print out

    I'd love for someone to explain how this works.

  8. Trans says:

    Ah, I see. The heart of the code is actually this:

    pids = []
    read, write = IO.pipe
    groups.each_with_index do |files, process_number|
    pids << Process.fork do
    write.puts ParallelTests.run_tests(files, process_number)

    Hmm... will that work for Windows?

  9. roger says:

    also check out spork for lightning fast spec_server

Other Posts to Enjoy

Twitter Mentions