Running Unit Tests With Artisan's Test Runner
In the 7.x branch, Laravel added an artisan test
command which acts as a wrapper for PHPUnit. It provides information about the tests as they’re running and stops on the first failure unlike PHPUnit’s default behavior of running all the tests and showing all the failures. It also provides a nice output when the tests fail.
The following article will provide a brief overview of how we can use it and quickly compare it to phpunit
.
To start out let’s look at what happens when we run phpunit
for our project.
Now let’s look at the same tests if we run php artisan test
.
The nice part of this feature is when we have a failing test. When running our test suite with a failing test we’ll get the following output from phpunit
.
However, if we run the test using php artisan test
we get the following nicer output.
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows