Skip to content
| Marketplace
Sign in
Visual Studio Code>Testing>PHPUnit RunnerNew to Visual Studio Code? Get it now.
PHPUnit Runner

PHPUnit Runner

AOS Software

|
24 installs
| (0) | Free
Run PHPUnit tests directly from VS Code with test discovery, execution, and result display
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PHPUnit Runner for VS Code

A comprehensive VS Code extension for running PHPUnit tests with integrated test discovery, execution, and result display.

Features

  • Test Discovery: Automatically discovers PHPUnit tests in your workspace
  • Test Explorer Integration: Tests appear in VS Code's built-in Test Explorer
  • Individual Test Execution: Run specific test methods or entire test files
  • Real-time Output: View PHPUnit output in real-time in the output panel
  • Context Menu Integration: Right-click on PHP test files to run tests
  • Configurable: Customize PHPUnit path, configuration file, and test directories

Requirements

  • VS Code 1.102.0 or higher
  • PHP installed and accessible from the command line
  • PHPUnit installed in your project (recommended via Composer)
  • Supported PHPUnit versions: 9.x, 10.x, 11.x (automatic version detection)

Installation

  1. Install the extension from the VS Code marketplace
  2. Open a workspace containing PHP tests
  3. Configure your PHPUnit settings if needed (see Configuration section)

Usage

Running Tests

Via Test Explorer:

  1. Open the Test Explorer panel (View → Test)
  2. Your tests will be automatically discovered and displayed
  3. Click the play button next to any test or test file to run it

Via Command Palette:

  1. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
  2. Run one of these commands:
    • PHPUnit: Run All Tests
    • PHPUnit: Refresh Tests
    • PHPUnit: Stop Tests

Via Context Menu:

  1. Right-click on a PHP test file in the editor or explorer
  2. Select "Run Test File"

Using Docker

To run tests inside a Docker container:

  1. Enable Docker mode:

    {
      "aos-phpunit.docker.enabled": true
    }
    
  2. Using Docker Compose (recommended):

    {
      "aos-phpunit.docker.enabled": true,
      "aos-phpunit.docker.useCompose": true,
      "aos-phpunit.docker.serviceName": "app",
      "aos-phpunit.docker.workingDirectory": "/var/www/html"
    }
    
  3. Using plain Docker:

    {
      "aos-phpunit.docker.enabled": true,
      "aos-phpunit.docker.useCompose": false,
      "aos-phpunit.docker.containerName": "my-php-container",
      "aos-phpunit.docker.workingDirectory": "/var/www/html"
    }
    

Note: Make sure your Docker container is running and has PHPUnit installed before running tests.

Configuration

Open VS Code settings and search for "PHPUnit" to configure the extension:

{
  "aos-phpunit.phpunitPath": "vendor/bin/phpunit",
  "aos-phpunit.configFile": "phpunit.xml",
  "aos-phpunit.testSuffix": "Test.php",
  "aos-phpunit.testDirectories": ["tests", "test"],
  "aos-phpunit.showOutput": true,
  "aos-phpunit.phpunitVersion": "",
  "aos-phpunit.docker.enabled": false,
  "aos-phpunit.docker.containerName": "",
  "aos-phpunit.docker.serviceName": "app",
  "aos-phpunit.docker.workingDirectory": "/var/www/html",
  "aos-phpunit.docker.useCompose": true,
  "aos-phpunit.docker.composeFile": "docker-compose.yml"
}

Configuration Options

Basic Settings

Setting Description Default
aos-phpunit.phpunitPath Path to PHPUnit executable relative to workspace root vendor/bin/phpunit
aos-phpunit.configFile Path to PHPUnit configuration file phpunit.xml
aos-phpunit.testSuffix Test file suffix pattern Test.php
aos-phpunit.testDirectories Directories to search for test files ["tests", "test"]
aos-phpunit.showOutput Show PHPUnit output in output panel true
aos-phpunit.phpunitVersion Override PHPUnit version detection (e.g., '9.5', '10.0', '11.0') "" (auto-detect)

Docker Settings

Setting Description Default
aos-phpunit.docker.enabled Enable running PHPUnit tests in a Docker container false
aos-phpunit.docker.containerName Name of the Docker container (used when not using docker-compose) ""
aos-phpunit.docker.serviceName Docker Compose service name "app"
aos-phpunit.docker.workingDirectory Working directory inside the Docker container "/var/www/html"
aos-phpunit.docker.useCompose Use docker-compose instead of plain docker command true
aos-phpunit.docker.composeFile Path to docker-compose file relative to workspace root "docker-compose.yml"

Commands

Command Description
aos-phpunit.runAllTests Run all discovered tests
aos-phpunit.runTestFile Run tests in the current file
aos-phpunit.refreshTests Refresh test discovery
aos-phpunit.stopTests Stop running tests

Release Notes

0.0.1

  • Initial release
  • Test discovery and execution
  • Test Explorer integration
  • Basic PHPUnit output parsing
  • Configurable settings

Enjoy!

// https://marketplace.visualstudio.com/manage/publishers/AOSSoftware?auth_redirect=True

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft