- Install phpunit.
- Set the config values:
{
"phpunit.execPath": "path/to/phpunit",
"phpunit.args": [
"--configuration", "./phpunit.xml.dist"
]
}
Run with (Cmd+Shift+P
on OSX or Ctrl+Shift+P
on Windows and Linux) and execute the PHPUnit Test
command.
- Test a function: Place cursor on a function and run.
- Test a class: Place cursor anywhere in class (except on a function) and run.
- Test everything according to --configuration: Close editor window and run.
- Test everything in a directory: Open a file in the directory to test and run the
PHPUnit Test Directory
command.
- execPath is recommended to set in your 'user settings'. Having phpunit in PATH doesn't work (at least on windows 10) =(.
- args is recommended to set in your 'workspace settings'. You can add any phpunit args, check phpunit --help.
- To hook into the debugger (github.com/felixfbecker/vscode-php-debug). Add Key:
XDEBUG_CONFIG
, Value:idekey=VSCODE
to your environment variables. (Tested on Windows 10)