PHPUnit Test Explorer Plugin for VScode

57 Views Asked by At

I'm new to VScode coming from PHPStorm only cause Github Copilot chat is better than PHPStorm. I'm having trouble setting up PHPUnit Test Explorer for VSCode. I always get this annoying error:

❌ Could not open input file: vendor/bin/phpunit

It works perfectly fine in PHPStorm and in VScode in the terminal (bash) when I run the command "./vendor/bin/phpunit --filter testSomeTestFunction". I'm trying to run my tests like in PHPStorm it's just the way I'm used to it.

My setup is Laravel Homestead/vagrant. I have PHP installed in my Windows 10 machine in: C:\php82

and my current project has a "server" directory where Laravel application is in.

This is my current VScode settings.json file:

{
    "editor.inlineSuggest.suppressSuggestions": true,
    "files.autoSave": "afterDelay",
    "phpunit.php": "C:\\php82\\php.exe",
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "editor.fontLigatures": true,
    "editor.fontSize": 13,
    "editor.lineHeight": 1.2,
    "[php]": {},
    "php.executablePath": "C:\\php82\\php.exe",
    "phpunit.clearOutputOnRun": true,
    "intelephense.environment.phpVersion": "8.1",
    "phpunit.paths": {
        "c:/Users/User/code/myproject/server": "./vendor/bin"
    }
}

My projects are in the typical "code" directory. If you need more info, definitely let me know.

1

There are 1 best solutions below

0
bhavin On

Try :

composer require --dev phpunit/phpunit

I made some changes in json below try this

{
    "editor.inlineSuggest.suppressSuggestions": true,
    "files.autoSave": "afterDelay",
    "phpunit.php": "C:\\php82\\php.exe",
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "editor.fontLigatures": true,
    "editor.fontSize": 13,
    "editor.lineHeight": 1.2,
    "[php]": {},
    "php.executablePath": "C:\\php82\\php.exe",
    "phpunit.clearOutputOnRun": true,
    "intelephense.environment.phpVersion": "8.1",
    "phpunit.paths": {
        "c:/Users/User/code/myproject/server": "./vendor/bin"
    },
    "phpunit.customOptions": {
        "testSuffix": ".php",
        "bootstrap": "c:/Users/User/code/myproject/server/bootstrap/app.php",
        "colors": "never"
    }
}