DEV Community

Recca Tsai
Recca Tsai

Posted on • Originally published at recca0120.github.io

PHPUnit for VSCode 3.0: VS Code Testing API and Docker

Originally published at recca0120.github.io

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:

{
  "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"
  }
}
Enter fullscreen mode Exit fullscreen mode

SSH Support:

{
  "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"
  }
}
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)