21. Oct 2022 |

php artisan test – No tests executed

I spend my time so that you don’t have to.

If you are getting the response “No tests executed” from php artisan test then please check that your test classes have their names in singular. ContactTest instead of ContactTests.

I spent like 3h to figure out why my Feature tests don’t run from command line while working well in phpStorm. The reason was that my class names were in plural.

 

18. Oct 2022 |

Laravel – run PHPUnit test on separate database (with phpStorm)

In phpStorm see Settings -> PHP -> Test Frameworks -> Test Runner. Check if you have default configuration file phpunit.xml checked. No need to change anything in this file.

Create .env.testing and copy whole DB_ block from .env (not just parts that are different). Change values to your test database values.

Then run php artisan config:clear which will clear configuration cache.

Everything should work 🙂

I spent several hours figuring it out. Hopefully you don’t.