PHPUnit Runner is a VS Code extension for discovering and running PHPUnit tests directly from the editor and the Testing view.
It parses PHPUnit test files, organizes them by folder structure, and lets you run the current file, the test at the cursor, or discovered tests from the VS Code test explorer.
- Discovers PHPUnit test files across the workspace (vendor and
node_modulesexcluded by default) - Auto-detects
phpunit.xml/phpunit.xml.distand reloads when they change - Detects test methods by:
test*method names@testdocblocks#[Test]and#[PHPUnit\Framework\Attributes\Test]attributes
- Organizes tests in the Testing panel by workspace, folders, files, classes, and methods
- Maps PHPUnit JUnit output onto individual Test Explorer items (pass / fail / skip)
- Debug and coverage run profiles (Xdebug listener + Clover overlay)
- Remote execution via a command template (Docker Compose, Laravel Sail, DDEV, SSH)
- Host-to-remote path mappings so failures and coverage open the local file
- Run all, rerun last, run failed, and run by
#[Group]/@group - Discovers tests from
phpunit.xmltestsuites when present - Shows assertion failures with file locations in the Test Results panel
- Run the current file from the editor title or context menu
- Run the test at the current cursor position
- Shows PHPUnit output in a dedicated output channel
- Supports local execution and Docker container execution
Install from the VS Code Marketplace.
Core settings:
phpunitRunner.phpExecutablephpunitRunner.phpunitCommandphpunitRunner.configurationFilephpunitRunner.workingDirectoryphpunitRunner.additionalArgsphpunitRunner.phpArgsphpunitRunner.commandphpunitRunner.pathsphpunitRunner.environmentphpunitRunner.saveBeforeTestphpunitRunner.testFileGlobsphpunitRunner.excludeGlobsphpunitRunner.debuggerConfigphpunitRunner.xdebugPort
Docker settings:
phpunitRunner.docker.enablephpunitRunner.docker.commandphpunitRunner.docker.containerphpunitRunner.docker.workspacePathphpunitRunner.docker.execArgs
{
"phpunitRunner.phpunitCommand": "vendor/bin/phpunit",
"phpunitRunner.configurationFile": "phpunit.xml"
}{
"phpunitRunner.docker.enable": true,
"phpunitRunner.docker.container": "app",
"phpunitRunner.docker.workspacePath": "/var/www/html",
"phpunitRunner.phpunitCommand": "vendor/bin/phpunit"
}{
"phpunitRunner.command": "docker compose exec -u sail laravel.test ${php} ${phpargs} ${phpunit} ${phpunitargs}",
"phpunitRunner.paths": {
"${workspaceFolder}": "/var/www/html"
}
}{
"phpunitRunner.command": "ddev exec ${php} ${phpargs} ${phpunit} ${phpunitargs}"
}{
"phpunitRunner.command": "ssh user@host \"cd ${cwd} && ${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
"phpunitRunner.paths": {
"${workspaceFolder}": "/app"
}
}PHPUnit Runner: Refresh TestsPHPUnit Runner: Run Current FilePHPUnit Runner: Run Test At CursorPHPUnit Runner: Run All TestsPHPUnit Runner: Rerun Last RunPHPUnit Runner: Run Failed TestsPHPUnit Runner: Run By GroupPHPUnit Runner: Show Output
- Source: https://github.com/ayanozturk/vscode-phpunit-runner
- License: MIT