PHPackages                             dmarynicz/behat-parallel-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. dmarynicz/behat-parallel-extension

ActiveLibrary[Testing &amp; Quality](/categories/testing)

dmarynicz/behat-parallel-extension
==================================

Parallel extension for Behat

v1.2.0(3mo ago)27544.3k—2.2%14[6 issues](https://github.com/Daniel-Marynicz/BehatParallelExtension/issues)MITPHPPHP &gt;=7.4CI passing

Since May 12Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/Daniel-Marynicz/BehatParallelExtension)[ Packagist](https://packagist.org/packages/dmarynicz/behat-parallel-extension)[ Docs](https://github.com/Daniel-Marynicz/BehatParallelExtension)[ RSS](/packages/dmarynicz-behat-parallel-extension/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (14)Versions (12)Used By (0)

Behat Parallel Extension
========================

[](#behat-parallel-extension)

[![Packagist Version](https://camo.githubusercontent.com/e30fb5db8ecc9c71b0e236acf52609160c43b4e0bb29dd2872db5e870430b106/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646d6172796e69637a2f62656861742d706172616c6c656c2d657874656e73696f6e3f6c6162656c3d76657273696f6e)](https://camo.githubusercontent.com/e30fb5db8ecc9c71b0e236acf52609160c43b4e0bb29dd2872db5e870430b106/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646d6172796e69637a2f62656861742d706172616c6c656c2d657874656e73696f6e3f6c6162656c3d76657273696f6e)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://github.com/Daniel-Marynicz/BehatParallelExtension/blob/master/LICENSE)[![PHP Tests](https://github.com/Daniel-Marynicz/BehatParallelExtension/actions/workflows/php.yml/badge.svg)](https://github.com/Daniel-Marynicz/BehatParallelExtension/actions/workflows/php.yml)

Intro
-----

[](#intro)

This extension is for an executing behat 3.x tests in parallel mode.

[![Behat Parallel Runner](parallel.apng?raw=true "Behat Parallel Extension with parallel mode enabled")](parallel.apng?raw=true)

If you Properly integrate your app with this extension then it can be dramatically speed up your behat tests!

### Features

[](#features)

- Displays nice progress bar :).
- Extension can cancel your tests when you hit CTRL+C.
- When you have failed tests in **Parallel scenario** mode then can you rerun this test with Behat option `--rerun`.
- For each worker you can set environment variables.
- You can group scenarios or features into a single job to improve test execution time by using the same kernel bootstrapped once.

### Main modes

[](#main-modes)

Behat Parallel Extension can work in two main modes:

- **Parallel scenario** witch can be enabled by option `--parallel` or `-l`.
- **Parallel feature** to enable this you need use behat option `--parallel-feature`.

- **Parallel chunk size** to group multiple scenarios or features into a single job, use the --parallel-chunk-size option (default is 1). Only available with Behat &gt;= 3.23

Requirements
------------

[](#requirements)

### PHP compatibility

[](#php-compatibility)

This Behat extension requires php `5.6` or higher. The main reason for choosing php 5.6 is to be able to share this tool with more programmers :).

Installing Behat Parallel Extension
-----------------------------------

[](#installing-behat-parallel-extension)

The most convenient way to install Behat Parallel Extension is by using [Composer](https://getcomposer.org):

For more information about installing [Composer](https://getcomposer.org) please follow the documentation:

### Install

[](#install)

```
composer  require --dev dmarynicz/behat-parallel-extension

```

Configuration
-------------

[](#configuration)

You can then activate and configure the extension in your `behat.yml` or `behat.yml.dist`. In the array `environments` you can set you environment vars for each worker. From this `environments` array depends on how much maximum you can run Workers. If you do note set `environments` array then you can run an unlimited amount of Workers. If the `environmental` array is defined, the maximum number of workers is the size of this array.

Example for maximum 4 Workers:

```
default:
    # ...
    extensions:
        DMarynicz\BehatParallelExtension\Extension:
          environments:
            -
              ANY_YOUR_ENV_VARIABLE: with any value
              DATABASE_URL:        mysql://db_user:db_password@127.0.0.1:3306/db_name_00?serverVersion=5.7
            -
              ANY_YOUR_ENV_VARIABLE: with any value
              DATABASE_URL:        mysql://db_user:db_password@127.0.0.1:3306/db_name_01?serverVersion=5.7
            -
              ANY_YOUR_ENV_VARIABLE: with any value
              DATABASE_URL:        mysql://db_user:db_password@127.0.0.1:3306/db_name_02?serverVersion=5.7
            -
              ANY_YOUR_ENV_VARIABLE: with any value
              DATABASE_URL:        mysql://db_user:db_password@127.0.0.1:3306/db_name_03?serverVersion=5.7
```

Example for maximum an unlimited amount of Workers:

```
default:
    # ...
    extensions:
        DMarynicz\BehatParallelExtension\Extension: ~
```

Integration with [SymfonyExtension](https://github.com/FriendsOfBehat/SymfonyExtension) and [Symfony](http://symfony.com)
-------------------------------------------------------------------------------------------------------------------------

[](#integration-with-symfonyextension-and-symfony)

To integrate this extension with [SymfonyExtension](https://github.com/FriendsOfBehat/SymfonyExtension) and [MinkExtension](https://github.com/FriendsOfBehat/MinkExtension) you need install by [Composer](https://getcomposer.org) command packages

```
composer require --dev \
    friends-of-behat/mink \
    friends-of-behat/mink-extension \
    friends-of-behat/mink-browserkit-driver \
    friends-of-behat/symfony-extension
```

Configure the extension in your `behat.yml` or `behat.yml.dist` as in this example:

```
default:
  suites:
    default:
      contexts:
        # Your contexts...
  extensions:
    Behat\MinkExtension:
      sessions:
        symfony:
          symfony: ~
    FriendsOfBehat\SymfonyExtension:
      # for symfony 5.3+ with symfony/runtime installed by composer command
      bootstrap: tests/bootstrap.php
      # for symfony versions older than 5.3
      #bootstrap: config/bootstrap.php

    DMarynicz\BehatParallelExtension\Extension:
      environments:
        - DATABASE_URL: "sqlite:///%%kernel.project_dir%%/var/data_test1.db"
          # doc for APP_CACHE_DIR https://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-cache-directory
          APP_CACHE_DIR: "var/cache1"
          # SYMFONY_DOTENV_VARS does not have symfony's docs but without this tests will ignore env vars like DATABASE_URL, APP_CACHE_DIR and tests will not work
          SYMFONY_DOTENV_VARS:
        - DATABASE_URL: "sqlite:///%%kernel.project_dir%%/var/data_test2.db"
          APP_CACHE_DIR: "var/cache2"
          SYMFONY_DOTENV_VARS:
        - DATABASE_URL: "sqlite:///%%kernel.project_dir%%/var/data_test3.db"
          APP_CACHE_DIR: "var/cache3"
          SYMFONY_DOTENV_VARS:
        - DATABASE_URL: "sqlite:///%%kernel.project_dir%%/var/data_test4.db"
          APP_CACHE_DIR: "var/cache4"
          SYMFONY_DOTENV_VARS:
```

In `tests/bootstrap.php` for [Symfony](http://symfony.com) 5.3+ you need to have

```
