Using Laravel's parallel testing inside your package tests

March 23rd, 2021

Laravel recently added parallel testing to the framework using the Paratest package which runs PHPUnit in separate parallel processes. Adding support for this in your own package tests is pretty straightforward using orchestral/testbench.

Testbench and more specifically testbench-core has added support for Laravel's parallel testing since 6.12.0, but it's recommended to at least use 6.19.0 where the new package:test command is hard-loaded instead of using package discovery. Using this inside your own package tests is very straightforward:

1. Add the necessary dependencies

This step isn't strictly necessary, as the command below will check for these and suggest them to be installed, but it's a bit faster to have them installed in advance.

composer require --dev brianium/paratest nunomaduro/collision

2. Run Testbench's new package:test command

Testbench has a new package:test command that mimics Laravel's test command, which sets up everything you need to have your package tested within Testbench's default Laravel project. You can run this with the --parallel flag to enable parallel testing.

./vendor/bin/testbench package:test --parallel

You can like or retweet this Tweet
MENU