Faster BDD: Parallelising Cucumber and re-running failed scenarios

Parallelising Cucumber

The ‘parallel_test‘ is a awesome rubygem to speedup your Rspec, Cucumber and Test Unit scenarios. Parallel _test also allows us to run Cucumber into different process and speedup the entire execution. In my previous blog post ‘speed up BDD with parallel cucumber‘ we have seen the basic setup of parallel-test, scenario execution and reports aggregation.

In this post, we will see how to handle flacky scenarios by re-running them with parallel cucumber.

Source Code

Source Code of this demo is available on GitHub ‘ parallel-cucumber-failed-rerun

https://github.com/Shashikant86/parallel-cucumber-failed-rerun

 

Setup

Inside cucumber.yml

if you got existing project add this to your cucumber.yml report logger as a new profile

 

This will created ‘cucumber_failures.log’ with all failed scenario which we can use it for rerunning.

You can also add another profile to generate html reports of each cucumber process.

Run features in parallel

Now, you can run your features in parallel using that profile

 

This will run your entire features into 10 different processes and logs failed scenarios in the ‘cucumber_failures.log’ file.

Re-run failed features

Now that, we got ‘cucumber_failures.log’ file with all failed scenarios. We can use that file to re-run failed cucumber scenarios. like this

 

Rakefile

You can put all things into one Rakefile i.e deleting reports, running in a parallel and re-running failed scenarios.

rakefile

 

Rakefile has 4 different tasks to perform different cucumber operations

cleanup

This task delete old html reports and cucumber failures log file and create new one for fresh execution.

parallel_cucumber

This task runs features in parallel and create ‘cucumber_failures.log’ file with failed scenarios.

rerun

This task will rerurn only failed scenarios.

test

This task will combine everything in one.

 Using Demo Project

You can start from simple demo on Github

 

You can watch video demo on Youtube here