Skip to content

Parallel Execution

glenn-barker edited this page Apr 2, 2019 · 10 revisions

As of the time of this writing, parallel execution of scenarios/features is not yet officially supported in the official behave release. However, there have been a number of forks (one of which has an unfulfilled PR into behave) that offer parallel execution support, to varying degrees of success.

Pre-requisites

Make sure you've followed the main installation steps for this framework to get everything, including the base behave package, installed and configured into a new virtual environment. We'll use that as a base and then overwrite the standard behave package with one from a fork that implements parallelization.

Install

From this project's root web-bdd directory:

$ git clone -b eparallel https://github.com/xrg/behave-parallel.git
$ cd behave-parallel
$ pipenv run python setup.py install

Running

With the above behave-parallel fork installed over top of the base behave module, you can now specify the --processes and --parallel-element cmd line args when running tests, e.g.:

$ pipenv run behave --processes 4 --parallel-element feature -D headless=true

Quirks with running behave in parallel

The behave-parallel fork we install over top of the base behave package is not entirely bug free and has a few quirks.

For instance, when running tests in parallel, even though all functionality will execute as you'd expect, the final output summary may falsely mark your steps/scenarios/features as untested rather than the expected passed or failed. For this reason, I don't recommend relying on the standard behave test results output for this and instead recommend using a custom logging / test results reporting mechanism when running tests in parallel.

Uninstall

If you want to uninstall the unofficial behave-parallel fork and revert back to the official master behave branch, the easiest way is to simply reset your virtual environment:

$ pipenv uninstall --all
$ pipenv install

Doing this won't touch the Pipfile or Pipfile.lock items at all and you will be back to a clean slate without any custom parallelization support. Then, if you want parallelization support again later, simply re-run the setup.py install line from the installation instructions above.

Clone this wiki locally