Home » Php » php – How to run phpunit in laravel 5.5

php – How to run phpunit in laravel 5.5

Posted by: admin July 12, 2020 Leave a comment


I have a problem running phpunit in my laravel 5.5. I already go to vendor/bin and then execute phpunit using my command prompt in windows. But cmd just give another option or flag as shown in the picture below :
enter image description here

I have read laravel 5.5 documentation for unittest. It’s said that we just need to execute phpunit {as shown in https://laravel.com/docs/5.5/testing}
Then I tried this :
How to run single test method with phpunit?

phpunit --filter testBasicTest tests\Unit\ExampleTest

As shown below :
enter image description here

BUt it’s said that ‘cannot open the file’. Then I Tried
phpunit ExampleTest, but still cannot open the file. So what’s wrong here…?
Thanks in advance

Note :
Here’s my phpunit.xml :
enter image description here

How to&Answers:

You need to run phpunit without getting inside the bin folder.

Try this:


This will load your phpunit.xml file. Otherwise it cannot load your configuration file. Unless if you don’t give spesific path:

vendor/bin/phpunit --configuration /path/to/laravels/phpunit.xml


Just install phpunit through composer:

composer global require phpunit/phpunit

then all you are set to test your laravel project.