9

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

2 Answers 2

25

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

Try this:

vendor/bin/phpunit

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
Sign up to request clarification or add additional context in comments.

4 Comments

I tried cd vendor/bin && phpunit but it still gives me the same result as above....
what about configuration?
there are so many phpunit.xml files located in different project folders, don't know which one is used for configuration
Also can be useful if you will use the Cygwin instead of default windows console
1

Just install phpunit through composer:

composer global require phpunit/phpunit

then all you are set to test your laravel project.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.