Laravel: Parallel Testing Is Now Available

Nuno Maduro
Nuno Maduro
...

As you may know, Laravel and PHPUnit execute your tests sequentially within a single process. However, a single process doesn’t use multiple cores; therefore, your test execution is seriously bottlenecked!

image

To mitigate this issue, we're excited to announce that Parallel Testing is now available in Laravel. Starting Laravel v8.25, you may use the built-in test Artisan command to run your tests simultaneously across multiple processes to significantly reduce the time required to run the entire test suite.

Using a solution built on top of Paratest, Laravel automatically handles creating and migrating a test database for each parallel process. Of course, other Laravel testing goodies - such as Storage::fake - are ready to be used in Parallel too.

image

Each individual test suite will receive varying benefits from parallel testing. In this example above, test execution was reduced from 13 seconds to 2 seconds - 5x times faster.

1: To get started, first ensure you are running the latest version of Collision and Laravel 8:

composer update nunomaduro/collision laravel/framework

2: Then, include the --parallel option when executing the test Artisan command:

php artisan test --parallel

Be sure to check out the Parallel Testing documentation at laravel.com/docs. There, you will find the available parallel testing options and the information about how to prepare certain resources so they may be safely used by multiple test processes. If you are curious, you can also check the pull request that adds Parallel Testing to Laravel.

We hope you enjoy this new addition to Laravel. Happy testing!

At Larasoft.io Ltd, We offer a web design company London at an unbeatable cost. Our main motive only is customer satisfaction.

Nuno Maduro
Nuno Maduro

Latest Stories

Here’s what we've been up to recently.

Request a code sample

Certified Quality. Great Prices

We use cookies to improve your experience and to help us understand how you use our site. By using this site, you accept our use of cookies. Cookie Infox