elonmallin/vscode-phpunit

only output, no real running of a test

Closed this issue · 6 comments

   ./vendor/phpunit/phpunit/phpunit --configuration ./tests/phpunit_all.xml 
   c:\Data\git\ANGEL\tests\Unit\Modules\Frontend\Controllers\CountryControllerTest.php

is shown in the output, but it won't run.

When I copy and paste it into the terminal window, it still won't run.

I have to add php before it to make it run.

So I did that in the configuration, and now I see that in the output window, but it still doesn't fire anything in the terminal window. How can I solve it?

Hi, please have a look at #7 (comment).

I think you have to use php as your execPath and the rest as args, including the path to phpunit as the first argument.

Ok, so this is what I have now:

    // phpunit
    "phpunit.execPath": "c:/Development/Laragon_lite/bin/php/php-7.2.9-nts-Win32-VC15-x64/php.exe",
    "phpunit.args": [
        "./vendor/phpunit/phpunit/phpunit --configuration ./tests/phpunit_all.xml"
    ],
    "phpunit.preferRunClassTestOverQuickPickWindow": false // Default false 

and in my output window, this shows:

c:/Development/Laragon_lite/bin/php/php-7.2.9-nts-Win32-VC15-x64/php.exe ./vendor/phpunit/phpunit/phpunit --configuration ./tests/phpunit_all.xml c:\Data\git\ANGEL\tests\Unit\Modules\Api\Controllers\ApiControllerTest.php
Could not open input file: ./vendor/phpunit/phpunit/phpunit --configuration ./tests/phpunit_all.xml

I even changed the config in full path's like this:

c:/Development/Laragon_lite/bin/php/php-7.2.9-nts-Win32-VC15-x64/php.exe c:/Data/git/ANGEL/vendor/phpunit/phpunit/phpunit --configuration c:/Data/git/ANGEL/tests/phpunit_all.xml c:\Data\git\ANGEL\tests\Unit\Modules\Api\Controllers\ApiControllerTest.php

Still the same error:

Could not open input file: c:/Data/git/ANGEL/vendor/phpunit/phpunit/phpunit --configuration c:/Data/git/ANGEL/tests/phpunit_all.xml

I try the same command from the terminal in VSC:

c:/Development/Laragon_lite/bin/php/php-7.2.9-nts-Win32-VC15-x64/php.exe ./vendor/phpunit/phpunit/phpunit --configuration ./tests/phpunit_all.xml c:\Data\git\ANGEL\tests\Unit\Modules\Api\Controllers\ApiControllerTest.php

and then I get the following message:

OK (6 tests, 8 assertions)

I don't know wjhat I can do or try to make this work... :-(

Sorry for the trouble, Windows is a little tricky. I have created a .bat file as my execPath.
phpunit.bat

php C:/Projects/testproj/vendor/phpunit/phpunit/phpunit %*

So I have this in my config:

"phpunit.execPath": "C:/Projects/testproj/vendor/bin/phpunit.bat"

Please see if that works. I have some pending changes to make it just find phpunit in the vendor directory automatically but It's not ready for release yet.

This should now work in the latest release v3.0.0 also published to the marketplace.

Now you don't need any config at all if you have php globally and phpunit installed with composer or as a .phar file in the project directory.

Please try and with this settings:

"phpunit.php": "c:/Development/Laragon_lite/bin/php/php-7.2.9-nts-Win32-VC15-x64/php.exe",
 "phpunit.args": [
     "--configuration ./tests/phpunit_all.xml"
 ],

Note that phpunit.execPath is now deprecated and replaced with phpunit.php. However it will still work but will be removed at some point.

Please close this issue if it works for you 👍

Doing it the other way around xP Closing this issue, please reopen if you have problems again.