Classic Docs
Docs Navigation

Running Cucumber scenarios in parallel

Semaphore lets you run Cucumber scenarios in parallel jobs. There are couple of ways to use this great feature:

# 1. Using Boosters

Semaphore Boosters are the easiest way to automatically parallelize your Cucumber test suite. With Boosters you don't need to make any changes to your source code. To learn more about Boosters visit our documentation page.

# 2. Using tags

Run cucumber tag groups in separate jobs.

RAILS_ENV=test CTAGS='--tags @tag_name' bundle exec rake cucumber default: features

# 3. Groups

You can use gem cucumber in groups and split your Cucumber features to run them separately.

# 4. Break by directory structure

You can split execution of scenarios by grouping them in subdirectories. e.g Let's say you have two directory within features, "foo" and "bar". Running scenarios from these two subdirectories in parallel jobs would be done as follows:

Note: In order for all the feature steps to be visible from each directory, you have to add the following line to your cucumber.yml file:

  default: -r features

# 5. Parallel Cucumber scenarios with Knapsack gem

If you want to get faster feedback from CI then you can try knapsack gem. It will split tests across jobs and make sure that tests will run comparable time on each job.

# Generate knapsack report

For the first time run all scenarios at once with enabled report generator. Set up your build command:

After tests pass your should copy knapsack json report which is rendered at the end of cucumber results. Save it into your repository as knapsack_cucumber_report.json file and commit. More info about generating report you will find in knapsack docs.

# Set up knapsack cucumber command

Knapsack supports Semaphore ENVs SEMAPHORE_THREAD_COUNT and SEMAPHORE_CURRENT_THREAD. The only thing you need to do is set up knapsack cucumber command for as many jobs as you need. Here is an example:

Scenarios will be split across jobs.

Semaphore Docs are open source — Edit on GitHub


Occasional lightweight product and blog updates. Unsubscribe at any time.

2009-2020 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.