Run Tests With PHP Artisan Test
Arie Visser • March 29, 2020php 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
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 you run the tests with
php artisan test, you will receive this:
Or, if we let one of the tests fail when running
phpnunit you will see this:
Whereas when you run a test that fails with
php artisan test it returns this output:
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"