recca0120 / vscode-phpunit

The VS Code Test Explorer extension for PHPUnit
MIT License
127 stars 44 forks source link

Running tests results in command failure. #135

Closed dclindner closed 1 year ago

dclindner commented 1 year ago

After I press the "Run Tests" button in the top of the TEST EXPLORER column, I immediately receive this error in my VS Code OUTPUT window (PHPUnit).

php vendor/bin/phpunit --teamcity --colors=never

❌ 
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../phpunit/phpunit" && pwd)

if [ -d /proc/cygdrive ]; then
    case $(which php) in
        $(readlink -n /proc/cygdrive)/*)
            # We are in Cygwin using Windows php, so the path must be translated
            dir=$(cygpath -m "$dir");
            ;;
    esac
fi

"${dir}/phpunit" "$@"

I can execute phpunit manual directly from the terminal window issuing a vendor/bin/phpunit command.

This worked in yesterday's load, but broke overnight in the latest push, it seems.

Thanks, Doug

recca0120 commented 1 year ago

can you remove the vendor folder, and execute composer install to reinstall PHPUnit?

dclindner commented 1 year ago

I deleted the PHPUNIT directory and performed another composer install. I restarted VSCODE and tried to execute the tests, but the problem remains. When I press the Run Tests button, I see a message displayed saying "Running tests", and then it immediately reports "0/0 tests passed (0.00%)". One thing that is odd is that the icon that is displayed beside each test file looks like a small circle (bullet), and not the normal icon. If it matters, I'm using PHP v8.1.9. As well, I can execute phpunit directly from a terminal window without issue.

recca0120 commented 1 year ago

do you have phpunit.xml ? It work fine in my windows and mac

you said old version worked fine, could you tell me what version is?

dclindner commented 1 year ago

I'm sorry for my tardy reply. I know you've just closed this, but I found a little more info that might be helpful.

One of my development systems works fine. It's a Windows 11/WSL installation, but mirrors the project set-up. The device that doesn't work is a Windows 10/non-WSL environment.

According to the following thread: https://stackoverflow.com/questions/68759365/setting-up-phpunit-php-cli-is-not-executing-the-shell-script

This may be due to how composer installs the bin files in various Windows environments.

On the machine on which it works, the file referenced at vendor/bin/phpunit is a php script.

On the machine on which it doesn't work, this same file is a shell script. Deleting the vendor directory and executing another composer install yields exactly the same result.

On both systems, executing "vendor/bin/phpunit" works.

Executing "php vendor/bin/phpunit" fails on one machine (W10), but works on the other (W11/WSL).

At the following URL: https://phpunit.de/getting-started/phpunit-9.html

The example given uses "vendor/bin/phpunit" on the CLI as the method to execute the test scripts.

How this translates to how PHPUnit Test Explorer, but I'm hoping that this little bit of info helps to clarify the problem.

Thanks!

recca0120 commented 1 year ago

on windows 10, set phpunit binary vendor/phpunit/phpunit/phpunit because on windows vendor/bin/phpunit will be vendor/bin/phpunit.bat

dclindner commented 1 year ago

Hi. I'm sorry, I don't understand your request. What would you like me to do exactly?

dclindner commented 1 year ago

I got it...it's in the settings of the plugin. I set it to "vendor/phpunit/phpunit/phpunit" and it now works find.

Thank you!