The Partial Runner is a Behat extension which runs a subset of scenarios to parallelize Behat across mutliple nodes.
This a fork from the original author of extension Anton Serdyuk with improvements made by TaysirTayyab
Where as shvetsgroup/ParallelRunner is an excellent tool for parallelizing Behat on a single machine, it unfortunately does not handle parallelizing Behat across multiple machines. The Behat Partial runner fills this gap.
It is very useful for CI services which offer parallelization such as CircleCI and TravisCI.
As this repository is a fork you have to add to your composer.json
root:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/drcreazy/behat-partial-runner.git",
"no-api": true
}
],
Require the extension with composer either through CLI or editing the composer.json
.
> bin/composer require --dev m00t/behat-partial-runner:0.0.2
Then and the extension to your behat.yml
file.
default:
extensions:
Behat\PartialRunner\ServiceContainer\PartialRunnerExtension: {}
Once configured, the parallelization can be invoked using the --count-workers
and --worker-number
options.
bin/behat --worker-number=0 --count-workers=2
bin/behat --worker-number=1 --count-workers=2
Note: The --worker-number
expects a 0-indexed node index.
To integrate with CircleCI, add the following to your circle.yml
file.
tests:
override: behat --worker-number=$CIRCLE_NODE_INDEX --count-workers=$CIRCLE_NODE_TOTAL:
parallel: true
To integerate with TravisCI, add the following to your .travis.yml
file.
script:
- behat --worker-number=$CI_NODE_INDEX --count-workers=$CI_NODE_TOTAL
env:
global:
- CI_NODE_TOTAL=2
matrix:
- CI_NODE_INDEX=0
- CI_NODE_INDEX=1
This project is set up with docker to simplify handling dependencies. By using docker, you are not required to install any additional packages or resources on your system, regardless of what sources the project may end up using in the future. All you need is the Docker Engine.
Once docker is installed, use the bundled script for composer to install the dependencies.
> bin/composer install
Usage is quite simple. Use the bundled scripts out of the project root directory. These will use the bundled php script for the php docker container.
> bin/behat
> bin/phpunit
(Adding ./bin
to you $PATH
variable may be helpful.)