Run selenium ruby scripts in parallel from Team City.

I recently found out why my automated tests run in parallel from my workstation, but then run in sequence from a team city build agent.  It all comes down to the rake runner in team city.  Team city uses a customized rake runner that extends rspec’s spec task.  You get all of the per test reporting, graphing and historical information from team city’s customized rspec reporting.  All this is great if you don’t mind running your tests in sequence, but If your using team city to launch automated web test using the selenium grid this is bad news.

I use a rake file to control the execution of my ruby selenium scripts. I modeled it from the ruby example in the selenium grid distribution. What is important to know about the run in parallel rake task is that it is not your normal rake task. It is first a rspec spec task.  This is a test runner from rspec that allows you to use a rake task to run specs. Not only is it a spec task, it also has been overridden by deep test, the software package that adds parallelization.  Since the spec task is actually deep test’s spec task and not the rspec spec task there are dependencies on what version of rspec deep tests needs.  You must run with rspec 1.1.8 so that the spec task that deep test overrides will work correctly.

So what happens when you run your deep test spec task from team city with their rake runner?   Deep test cannot launch your tests in parallel because Team City is using their customized spec task.  The solution is to use the command line runner to launch your rake task for the selenium grid, then your spec task will have access to the correct rspec gem for deep test to use as a spec runner.


  1. Roman.Chernyatchik says:


    I’m author of Rake runner plugin for TeamCity. TeamCity uses only customized test formatter with rake tasks which is specified in rake runner options. Also TeamCity defines SPEC_OPTS which is used for attaching our custom runner to user’s rake task. More over you can specify some spec options in Rake runner settings because SPEC_OPTS env variable overrides all spec options in spec rake task. Honestly I haven’t ever tried to launch selenium tests using Rake runner and I haven’t investigate it yet.

    > Deep test cannot launch your tests in parallel because Team City is using their customized spec task.
    So it should work but I’m not sure that build log and tests statistics will be correct for parallel tests execution.

  2. ssims says:

    I wanted to update this post with more information on rspec. I was able to checkout the most recent version of deep test from github. This version of deep test is more updated than the released gem. It allows you to use rspec 1.1.12.