Parallel Testing

Laravel introduced parallel testing in version 8.25open in new window. Behind the scenes, ParaTestopen in new window is used to split your tests up, and spawn several processes to run them at the same time.

Although this adds a some initial overhead (as the extra processes boot), it gives the benefit of having tests running simultaneously.

Adapt detects when tests are being run like this, and creates a separate database for each process by appending _1, _2, _3 (etc) to the name.

Run one of the following commands to run your tests in parallel:

# run tests in parallel using Laravel's command
php artisan test --parallel
# run tests in parallel using Pest (if you use Pest)
./vendor/bin/pest --parallel
# run tests in parallel using ParaTest directly
./vendor/bin/paratest

TIP

Adapt allows you to run your browser tests in parallel as well, just make sure you've added them as a test-suite to phpunit.xml, so they're included.

NOTE

Don't use the --recreate-databases command line option when parallel testing. The reason why is that this is Laravel functionality. Laravel will remove the databases it would build (if they exist), and not the databases that Adapt creates.

Adapt will clean up old databases automatically anyway, so there's no need to remove them manually.

Run php artisan adapt:clear if you really do want to remove them yourself.