Skip to content

Repository files navigation

PHPUnit Runner

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.

Features

  • Discovers PHPUnit test files across the workspace (vendor and node_modules excluded by default)
  • Auto-detects phpunit.xml / phpunit.xml.dist and reloads when they change
  • Detects test methods by:
    • test* method names
    • @test docblocks
    • #[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.xml testsuites 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

Installation

Install from the VS Code Marketplace.

Configuration

Core settings:

  • phpunitRunner.phpExecutable
  • phpunitRunner.phpunitCommand
  • phpunitRunner.configurationFile
  • phpunitRunner.workingDirectory
  • phpunitRunner.additionalArgs
  • phpunitRunner.phpArgs
  • phpunitRunner.command
  • phpunitRunner.paths
  • phpunitRunner.environment
  • phpunitRunner.saveBeforeTest
  • phpunitRunner.testFileGlobs
  • phpunitRunner.excludeGlobs
  • phpunitRunner.debuggerConfig
  • phpunitRunner.xdebugPort

Docker settings:

  • phpunitRunner.docker.enable
  • phpunitRunner.docker.command
  • phpunitRunner.docker.container
  • phpunitRunner.docker.workspacePath
  • phpunitRunner.docker.execArgs

Local example

{
  "phpunitRunner.phpunitCommand": "vendor/bin/phpunit",
  "phpunitRunner.configurationFile": "phpunit.xml"
}

Docker example

{
  "phpunitRunner.docker.enable": true,
  "phpunitRunner.docker.container": "app",
  "phpunitRunner.docker.workspacePath": "/var/www/html",
  "phpunitRunner.phpunitCommand": "vendor/bin/phpunit"
}

Laravel Sail / Docker Compose

{
  "phpunitRunner.command": "docker compose exec -u sail laravel.test ${php} ${phpargs} ${phpunit} ${phpunitargs}",
  "phpunitRunner.paths": {
    "${workspaceFolder}": "/var/www/html"
  }
}

DDEV

{
  "phpunitRunner.command": "ddev exec ${php} ${phpargs} ${phpunit} ${phpunitargs}"
}

SSH

{
  "phpunitRunner.command": "ssh user@host \"cd ${cwd} && ${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
  "phpunitRunner.paths": {
    "${workspaceFolder}": "/app"
  }
}

Commands

  • PHPUnit Runner: Refresh Tests
  • PHPUnit Runner: Run Current File
  • PHPUnit Runner: Run Test At Cursor
  • PHPUnit Runner: Run All Tests
  • PHPUnit Runner: Rerun Last Run
  • PHPUnit Runner: Run Failed Tests
  • PHPUnit Runner: Run By Group
  • PHPUnit Runner: Show Output

Repository

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages