6

Hi i am quit new in Laravel PHPUnit, getting the following error :

Laravel : phpunit cannot open file ExampleTest.php

I don't have idea why i am getting this error. I installed PHPUnit globally and when i run "phpunit" in terminal it runs fine. But I want to run it on specific file like :

phpunit ExampleTest

Thanks In Advance.

5 Answers 5

5

Make sure you are on the project root and referencing the file inside the tests folder.

Example:

phpunit tests/ExampleTest.php
Sign up to request clarification or add additional context in comments.

Comments

2

I am working in Windows. Try to use the full path:

C:\Desktop\code\blog\vendor\bin>phpunit C:\Desktop\code\blog\tests\Feature\ExampleTest.php
PHPUnit 7.2.6 by Sebastian Bergmann and contributors.
.                                                                   1 / 1 (100%)
Time: 1.46 seconds, Memory: 10.00MB
OK (1 test, 1 assertion)

1 Comment

In my Windows server it also worked with relative path of test .php file from laravel installation
1

This started happening when I upgrade phpUnit, I had to update phpStorm to fix it.

Comments

0

try it like this:

vendor\bin\phpunit tests\Unit\ExampleTest.php

it will work surly but first install phpunit globally.

Comments

0

Maybe you call wrong to your test. Try like this :

php artisan test --filter YourTestClassName

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.