To improve my quality of code, I\'ve decided to try to learn how to test my code using Unit Testing instead of my mediocre-at-best testing solutions.
Came late to the party, but this info may help others.
Above solutions did not work for me. As of Laravel 7.x, by default, PHPUnit executes only PHP files which are suffixed with "Test.php". For example if you create a test, naming it CreateUser
will not work, whereas naming it CreateUserTest
will work.
To overcome the limitation, go to phpunit.xml
and modify suffix
attribute from directory
elements:
...
./tests/Unit
./tests/Feature
...
This will instruct PHPUnit to run all files with .php
extension from directories. Note to clear app's cache after updating phpunit.xml
:
php artisan config:cache
Additional information about PHPUnit XML configuration can be found here: https://phpunit.de/manual/6.5/en/appendixes.configuration.html