Featured image of post PHPUnit for VSCode 3.0: VS Code Testing API and Docker

PHPUnit for VSCode 3.0: VS Code Testing API and Docker

A complete rewrite of PHPUnit for VSCode using the VS Code Testing API for real-time sidebar results, now with Docker and SSH remote execution support.

VSCode released a new Testing API, and the 2.0 version wasn’t designed with Docker and SSH use cases in mind, so I completely rewrote PHPUnit For VSCode.

Improvements in 3.0

VSCode Testing API Integration: The test list shows directly in the VSCode sidebar, and error messages are displayed inline in the editor.

PHPUnit Output Formatting: Switched to parsing the TeamCity protocol, reporting results in real time as each TestCase completes, unlike 2.0 which required waiting for the entire run to finish.

Docker Support:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "phpunit.command": "docker run --rm -t -v ${pwd}:/app -w /app php:latest php",
  "phpunit.php": "php",
  "phpunit.phpunit": "vendor/bin/phpunit",
  "phpunit.args": [
    "-c",
    "phpunit.xml"
  ],
  "phpunit.paths": {
    "${workspaceFolder}": "/app"
  }
}

SSH Support:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "phpunit.command": "ssh -i dockerfiles/sshd/id_rsa -p 2222 root@localhost -o StrictHostKeyChecking=no",
  "phpunit.php": "php",
  "phpunit.phpunit": "/app/vendor/bin/phpunit",
  "phpunit.args": [
    "-c",
    "/app/phpunit.xml"
  ],
  "phpunit.paths": {
    "${workspaceFolder}": "/app"
  }
}

Feel free to file an issue on GitHub if you run into any problems.