Webiondev123's avatar

phpunit testing cannot find file and cannot test globally

I am unable to run phpunit test from root folder but when I change to vender/bin I can run phpunit but cannot test. It says cannot open file

c:\wamp64\www\fundtheneedy>phpunit
'phpunit' is not recognized as an internal or external command,
operable program or batch file.


c:\wamp64\www\fundtheneedy\vendor\bin>phpunit ExampleTest


Cannot open file "ExampleTest.php".
0 likes
3 replies
tykus's avatar

You can run your full test suite if you run the following from the commandline

$ vendor/bin/phpunit

You can alias this to phpunit in your .bashrc or .zshrc file so that it is available in the root of any project:

alias phpunit="vendor/bin/phpunit"
Webiondev123's avatar

From windows command line it givs

c:\wamp64\www\fundtheneedy>vendor/bin/phpunit
'vendor' is not recognized as an internal or external command,
operable program or batch file.

Also where do I create .bashrc file? in my root laravel app? That makes it .bashrc.sh which I tried but still not working

tykus's avatar
tykus
Best Answer
Level 104

Actually missed the c:\ bit... I don't use Windows, so not sure what the optimal solution might be for a local project installation.

I would think that you could install PHPUnit globally and ensuring that the composer/bin directory in your User directory is included in your PATH, you could use phpunit anywhere throughout your system.

1 like

Please or to participate in this conversation.