Just released! Manage your Laravel projects with Invoker. The no-bull Laravel admin panel.
Run Tests With PHP Artisan Test cover image

Run Tests With PHP Artisan Test

Arie Visser • March 29, 2020

php phpunit

How does it work?

Since the release of Laravel 7.x, you can run you tests by executing

php artisan test

as an alternative to running your tests with the phpunit command.

This command will run all your tests, until the first test that fails.


The major differences from running your tests with phpunit can be seen in the output of your terminal.

When we run the tests in this example project about fluent string operations with phpunit, you will see this output:

alt text

When you run the tests with php artisan test, you will receive this:

alt text

Or, if we let one of the tests fail when running phpnunit you will see this:

alt text

Whereas when you run a test that fails with php artisan test it returns this output:

alt text

To summarize, php artisan test will:

1). Show the actual names of the tests that are running.

2). Stop at the first test that fails, subsequent tests are marked as pending.

3). Show the assertion that fails and the method of the test wherein it is executed.


As stated in the Laravel docs, you can pass all the arguments to the test command that may be passed to the phpunit command as well, e.g.:

php artisan test --testsuite="Api"

php artisan test --filter="StringOperationsTest"