PHPackages                             liuggio/fastest - 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. liuggio/fastest

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

liuggio/fastest
===============

Simple parallel testing execution... with some goodies for functional tests.

v1.14.2(2mo ago)4825.6M—7.3%71[11 issues](https://github.com/liuggio/fastest/issues)[6 PRs](https://github.com/liuggio/fastest/pulls)20MITPHPPHP ^8.0CI passing

Since Sep 18Pushed 2mo ago8 watchersCompare

[ Source](https://github.com/liuggio/fastest)[ Packagist](https://packagist.org/packages/liuggio/fastest)[ RSS](/packages/liuggio-fastest/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (35)Used By (20)

Fastest - simple parallel testing execution
===========================================

[](#fastest---simple-parallel-testing-execution)

[![example branch parameter](https://github.com/liuggio/fastest/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/liuggio/fastest/actions/workflows/build.yml/badge.svg?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/e9ffa7d2de2febc69d821e053c58c8ca603851dc4f918f8ad650ba4d8920a665/68747470733a2f2f706f7365722e707567782e6f72672f6c69756767696f2f666173746573742f762f737461626c652e737667)](https://packagist.org/packages/liuggio/fastest) [![Latest Unstable Version](https://camo.githubusercontent.com/f80af50c5d6020a3e26f9ba7cc207585d1bfc32f4299d61fc790ac00efef30f1/68747470733a2f2f706f7365722e707567782e6f72672f6c69756767696f2f666173746573742f762f756e737461626c652e737667)](https://packagist.org/packages/liuggio/fastest)

Only one thing
--------------

[](#only-one-thing)

**Execute parallel commands, creating a Process for each Processor (with some goodies for functional tests).**

```
find tests/ -name "*Test.php" | ./vendor/liuggio/fastest/fastest "vendor/phpunit/phpunit/phpunit -c app {};"
```

Fastest works with **any available testing tool**! It just executes it in parallel.

It is optimized for functional tests, giving an easy way to work with N databases in parallel.

Motto
-----

[](#motto)

> "I had a problem,
> so I decided to use threads.
> tNwoowp rIo bhlaevmes.

Why
---

[](#why)

We were tired of not being able to run [paratest](https://github.com/brianium/paratest) with our project (big complex functional project).
[Parallel](https://github.com/grosser/parallel) is a great tool but not so nice for functional tests.
There were no simple tool available for functional tests.

Our old codebase run in 30 minutes, now in 7 minutes with 4 Processors.

Features
--------

[](#features)

1. Functional tests could use a database per processor using the environment variable.
2. Tests are randomized by default.
3. Is not coupled with PhpUnit you could run any command.
4. Is developed in PHP with no dependencies.
5. As input you could use a `phpunit.xml.dist` file or use pipe (see below).
6. Includes a Behat extension to easily pipe scenarios into fastest.
7. Increase Verbosity with -v option.
8. Works with a installation in project or global mode

How
---

[](#how)

It creates N threads where N is the number of the core in the computer.
Really fast, 100% written in PHP, inspired by [Parallel](https://github.com/grosser/parallel).

Usage
-----

[](#usage)

### Configure paths to binaries

[](#configure-paths-to-binaries)

Examples shown below use paths to binaries installed in the `vendor/` directory. You can use symlinks in the `bin/` directory by defining the [`bin-dir` parameter of Composer](https://getcomposer.org/doc/06-config.md#bin-dir):

```
composer config "bin-dir" "bin"

```

Then you'll be able to call binaries in the `bin/` directory:

- `bin/fastest` instead of `vendor/liuggio/fastest/fastest`
- `bin/phpunit` instead of `vendor/phpunit/phpunit/phpunit`

### Parallelize everything

[](#parallelize-everything)

```
ls | ./fastest "echo slow operation on {}" -vvv
```

#### Using the placeholders

[](#using-the-placeholders)

`{}` is the current test file.
`{p}` is the current processor number.
`{n}` is the unique number of the current test. `phpunit {}` is used as default command.

### PHPUnit

[](#phpunit)

#### A. Using `ls`, list of folders as input **suggested**

[](#a-using-ls-list-of-folders-as-input-suggested)

```
ls -d test/* | ./vendor/liuggio/fastest/fastest "vendor/phpunit/phpunit/phpunit {};"
```

#### B. using `find`, list of php files as input

[](#b-using-find-list-of-php-files-as-input)

```
find tests/ -name "*Test.php" | ./vendor/liuggio/fastest/fastest  "vendor/phpunit/phpunit/phpunit {};"
```

#### C. Using `phpunit.xml.dist` as input

[](#c-using-phpunitxmldist-as-input)

You can use the option `-x` and import the test suites from the `phpunit.xml.dist`

`./vendor/liuggio/fastest/fastest -x phpunit.xml.dist "vendor/phpunit/phpunit/phpunit {};"`

If you use this option make sure the test-suites contains a lot of directories: **this feature should be improved, don't blame help instead.**

### Functional tests and database

[](#functional-tests-and-database)

Inside your tests you could use the env. variables,
if you are running tests on a computer that has 4 core, `fastest` will create 4 threads in parallel, and inside your test you could use those variables to better identify the current process:

```
echo getenv('ENV_TEST_CHANNEL');          // The number of the current channel that is using the current test eg.2
echo getenv('ENV_TEST_CHANNEL_READABLE'); // Name used to make the database name unique, is a readable name eg. test_2
echo getenv('ENV_TEST_CHANNELS_NUMBER');  // Max channel number on a system (the core number) eg. 4
echo getenv('ENV_TEST_ARGUMENT');         // The current running test eg. tests/UserFunctionalTest.php
echo getenv('ENV_TEST_INC_NUMBER');       // Unique number of the current test eg. 32
echo getenv('ENV_TEST_IS_FIRST_ON_CHANNEL'); // Is 1 if is the first test on its thread useful for clear cache.
```

### Setup the database `before`

[](#setup-the-database-before)

You can also run a script per process **before** the tests, useful for init schema and fixtures loading.

```
find tests/ -name "*Test.php" | ./vendor/liuggio/fastest/fastest -b"app/console doc:sch:create -e test" "vendor/phpunit/phpunit/phpunit {};";
```

### Generate and merge code coverage (or junit files)

[](#generate-and-merge-code-coverage-or-junit-files)

```
# Install phpcov in order to merge the code coverage
composer require --dev phpunit/phpcov
# Create a directory where the coverage files will be put
mkdir -p cov/fastest/
# Generate as many files than tests, since {n} is an unique number for each test
find tests/ -name "*Test.php" | vendor/liuggio/fastest/fastest "vendor/phpunit/phpunit/phpunit -c app {} --coverage-php cov/fastest/{n}.cov;"
# Merge the code coverage files
phpcov merge cov/fastest/ --html cov/merge/fastest/
```

Code coverage will be available in the `cov/merge/fastest/` directory.

This can also be used for junit using an alternative library [phpunit-merger](https://github.com/Nimut/phpunit-merger).

Storage adapters
----------------

[](#storage-adapters)

If you want to parallel functional tests, and if you have a machine with 4 CPUs, the best thing you could do is create a db foreach parallel process, `fastest` gives you the opportunity to work easily with Symfony.

Modifying the `config_test.yml` config file in Symfony, each functional test will look for a database called `_test_x` automatically (x is from 1 to CPUs number).

### Doctrine DBAL

[](#doctrine-dbal)

`config_test.yml`

```
parameters:
    # Stubs
    doctrine.dbal.connection_factory.class: Liuggio\Fastest\Doctrine\DBAL\ConnectionFactory
```

### Doctrine MongoDB Connection

[](#doctrine-mongodb-connection)

`config_test.yml`

```
parameters:
    # Stubs
    doctrine_mongodb.odm.connection.class: Liuggio\Fastest\Doctrine\MongoDB\Connection
```

### SQLite databases

[](#sqlite-databases)

SQLite databases don't have names. It's always 1 database per file. If SQLite driver is detected, instead switching the database name, database path will be changed. To make it work simply add `__DBNAME__` placeholder in your database path.

`config_test.yml`

```
doctrine:
    dbal:
        driver:   pdo_sqlite
        path:     "%kernel.cache_dir%/__DBNAME__.db"

parameters:
    doctrine.dbal.connection_factory.class: Liuggio\Fastest\Doctrine\DBAL\ConnectionFactory
```

Where `__DBNAME__` will be replaced with `ENV_TEST_CHANNEL_READABLE` value.

### Behat.\* extension

[](#behat-extension)

A Behat extension is included that provides the ability for Behat to output a list of feature files or individual scenarios that would be executed without actually executing them. This list can be piped into fastest to run the scenarios in parallel.

To install the extension just add it to your `behat.yml` file:

```
extensions:
    Liuggio\Fastest\Behat\ListFeaturesExtension\Extension: ~
```

for Behat2:

```
extensions:
    Liuggio\Fastest\Behat2\ListFeaturesExtension\Extension: ~
```

After this you will have two additional command line options: `--list-features` and `--list-scenarios`. The former will output a list of \*.feature files and the later will output each scenario of each feature file, including its line number (e.g. /full/path/Features/myfeature.feature:lineNumber)

This will let you pipe the output directly into fastest to parallelize its execution:

```
/my/path/behat --list-scenarios | ./vendor/liuggio/fastest/fastest "/my/path/behat {}"

```

While using `--list-scenarios` might be preferred over `--list-features` because it will give a more granular scenario-by-scenario output, allowing fastest to shuffle and balance individual tests in a better way... this can lead to a problem merging junit output e.g.

```
  Scenario Outline: my scenario
    Given some setup
    When I do
    Then I see

  Examples:
    | variable |
    | a        |
    | b        |

```

Both of the separate junit xml files detail the testcase as name my `scenario #1` which confuses the merging logic. For this reason `--list-features` might be safer.

Take care with using `--tags` in the behat command piping into fastest to then use the same tag list within the second behat call. This is because one may have a default tag set within its default profile in the `behat.yml` and this may result in scenarios not being found and therefore not being executed.

### About browser-based tests (Selenium, Mink, etc)

[](#about-browser-based-tests-selenium-mink-etc)

When a browser is controlled remotely via PHPUnit, Behat or another test suite that is being used by Fastest, the browser makes requests back to the server. The problem is that when the server process the request it has no idea of which fastest channel called it, so there must be a way to set this information before connecting to the database (in order to choose the correct database that corresponds to the channel).

One possible way is to implement the following steps:

#### 1. Set a cookie, GET query parameter or HTTP header with the appropriate channel value

[](#1-set-a-cookie-get-query-parameter-or-http-header-with-the-appropriate-channel-value)

When your test scenario begins, maybe at the authentication phase, set one of the following to the value of the environment variable `ENV_TEST_CHANNEL_READABLE`:

- If it's a cookie or a GET query parameter name it ENV\_TEST\_CHANNEL\_READABLE
    - Beware that if you use the GET query parameter option and via automation you click on a link of the browser that doesn't have that query parameter, the request won't have the query parameter the server won't know the channel to initialize.
- If it's a HTTP header name it X-FASTEST-ENV-TEST-CHANNEL-READABLE and send it on every request to the server.

#### 2. Configure the entry point of your application to set the environment variables for the request

[](#2-configure-the-entry-point-of-your-application-to-set-the-environment-variables-for-the-request)

For this is enough to add the following code before booting your application:

```
\Liuggio\Fastest\Environment\FastestEnvironment::setFromRequest();

```

This will detect the presence of the ENV\_TEST\_CHANNEL\_READABLE value in any of the contexts mentioned in #1 and set the corresponding environment variable.

For example, in the case of the Symfony framework you may just add it in `web/app_dev.php` just before `require_once __DIR__.'/../app/AppKernel.php'`:

```
// ... code
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();

\Liuggio\Fastest\Environment\FastestEnvironment::setFromRequest();

require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
// ... code
```

Install
-------

[](#install)

If you use Composer just run `composer require --dev 'liuggio/fastest:^1.6'`

or simply add a dependency on liuggio/fastest to your project's composer.json file:

```
{
    "require-dev": {
	    "liuggio/fastest": "^1.6"
    }
}

```

For a system-wide installation via Composer, you can run:

`composer global require "liuggio/fastest=^1.6"`

Make sure you have `~/.composer/vendor/bin/` in your path, read more at [getcomposer.org](https://getcomposer.org/doc/00-intro.md#globally)

If you want to use it with phpunit you may want to install phpunit/phpunit as dependency.

### Run this test with `fastest`

[](#run-this-test-with-fastest)

```
Usage:
 fastest [-p|--process="..."] [-b|--before="..."] [-x|--xml="..."] [-o|--preserve-order] [--no-errors-summary] [execute]

Arguments:
 execute               Optional command to execute.

Options:
 --process (-p)        Number of parallel processes, default: available CPUs.
 --before (-b)         Execute a process before consuming the queue, it executes this command once per process, useful for init schema and load fixtures.
 --xml (-x)            Read input from a phpunit xml file from the '' collection. Note: it is not used for consuming.
 --preserve-order (-o) Queue is randomized by default, with this option the queue is read preserving the order.
 --rerun-failed (-r)   Re-run failed test with before command if exists.
 --no-errors-summary   Do not display all errors after the test run. Useful with --vv because it already displays errors immediately after they happen.
 --no-progress         Do not display progress bar when running.
 --help (-h)           Display this help message.
 --quiet (-q)          Do not output any message.
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version.
 --ansi                Force ANSI output.
 --no-ansi             Disable ANSI output.
 --no-interaction (-n) Do not ask any interactive question.

```

e.g. `./fastest -x phpunit.xml.dist -v "bin/phpunit {}"`

### Known problems

[](#known-problems)

If you're facing problems with unknown command errors, make sure your [variables-order](http://us.php.net/manual/en/ini.core.php#ini.variables-order) `php.ini` setting contains `E`. If not, your environment variables are not set, and commands that are in your `PATH` will not work.

### Contribution

[](#contribution)

Please help with code, love, feedback and bug reporting.

Thanks to:

- @giorrrgio for the mongoDB adapter
- @diegosainz for the Behat2 adapter
- @barryswaisland-eagleeye for some updated docs
- you?

### License [![License](https://camo.githubusercontent.com/955324bb016dc9532936db2bdce1d010fc5941af1ffd334296e34dcbc04e52e2/68747470733a2f2f706f7365722e707567782e6f72672f6c69756767696f2f666173746573742f6c6963656e73652e737667)](https://packagist.org/packages/liuggio/fastest)

[](#license-)

Read [LICENSE](./LICENSE) for more information.

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance87

Actively maintained with recent releases

Popularity65

Solid adoption and visibility

Community41

Growing community involvement

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~139 days

Recently: every ~183 days

Total

31

Last Release

63d ago

Major Versions

0.0-alpha2 → 1.02015-09-23

PHP version history (7 changes)v1.4.0PHP &gt;=5.6

v1.6.0PHP ^5.6|^7.0

v1.7.0PHP ^7.2

v1.7.2PHP ^7.3

v1.8.0PHP ^7.3 || ^8.0

v1.10.0PHP ^7.4|^8.0

v1.13.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/446a646f719434553ab25f0f931d28ec09fbb036528126ac7e9d54a2e8132581?d=identicon)[liuggio](/maintainers/liuggio)

---

Top Contributors

[![DonCallisto](https://avatars.githubusercontent.com/u/7060632?v=4)](https://github.com/DonCallisto "DonCallisto (82 commits)")[![liuggio](https://avatars.githubusercontent.com/u/530406?v=4)](https://github.com/liuggio "liuggio (69 commits)")[![loostro](https://avatars.githubusercontent.com/u/39191878?v=4)](https://github.com/loostro "loostro (30 commits)")[![francoispluchino](https://avatars.githubusercontent.com/u/567393?v=4)](https://github.com/francoispluchino "francoispluchino (14 commits)")[![perk11](https://avatars.githubusercontent.com/u/1924829?v=4)](https://github.com/perk11 "perk11 (7 commits)")[![alexislefebvre](https://avatars.githubusercontent.com/u/2071331?v=4)](https://github.com/alexislefebvre "alexislefebvre (6 commits)")[![tarlepp](https://avatars.githubusercontent.com/u/595561?v=4)](https://github.com/tarlepp "tarlepp (6 commits)")[![peterrehm](https://avatars.githubusercontent.com/u/2010989?v=4)](https://github.com/peterrehm "peterrehm (5 commits)")[![diego-sainz-g](https://avatars.githubusercontent.com/u/128644680?v=4)](https://github.com/diego-sainz-g "diego-sainz-g (4 commits)")[![aitboudad](https://avatars.githubusercontent.com/u/1753742?v=4)](https://github.com/aitboudad "aitboudad (4 commits)")[![wcluijt](https://avatars.githubusercontent.com/u/627499?v=4)](https://github.com/wcluijt "wcluijt (2 commits)")[![alex-you-know](https://avatars.githubusercontent.com/u/219658454?v=4)](https://github.com/alex-you-know "alex-you-know (2 commits)")[![biederKdo](https://avatars.githubusercontent.com/u/8696555?v=4)](https://github.com/biederKdo "biederKdo (2 commits)")[![Grldk](https://avatars.githubusercontent.com/u/33746490?v=4)](https://github.com/Grldk "Grldk (2 commits)")[![mnocon](https://avatars.githubusercontent.com/u/10993858?v=4)](https://github.com/mnocon "mnocon (2 commits)")[![jdmaguire](https://avatars.githubusercontent.com/u/2904542?v=4)](https://github.com/jdmaguire "jdmaguire (1 commits)")[![joshuataylor](https://avatars.githubusercontent.com/u/225131?v=4)](https://github.com/joshuataylor "joshuataylor (1 commits)")[![kix](https://avatars.githubusercontent.com/u/345754?v=4)](https://github.com/kix "kix (1 commits)")[![javiereguiluz](https://avatars.githubusercontent.com/u/73419?v=4)](https://github.com/javiereguiluz "javiereguiluz (1 commits)")[![giorrrgio](https://avatars.githubusercontent.com/u/482501?v=4)](https://github.com/giorrrgio "giorrrgio (1 commits)")

---

Tags

hacktoberfesthacktoberfest2020

###  Code Quality

TestsBehat

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/liuggio-fastest/health.svg)

```
[![Health](https://phpackages.com/badges/liuggio-fastest/health.svg)](https://phpackages.com/packages/liuggio-fastest)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
