A VS Code extension that provides run buttons for individual PHPUnit test methods.
- CodeLens Integration: Shows "▶ Run Test" buttons above each test method
- Custom PHPUnit Command: Configurable command and arguments
- Terminal Integration: Runs tests in VS Code's integrated terminal
- Smart Detection: Automatically detects test files and methods
- Open a PHP test file (files ending with
Test.phpor in/test/or/tests/directories) - You'll see "▶ Run Test" buttons above each test method
- Click the button to run that specific test
The extension will execute your custom PHPUnit command with the --filter parameter. It uses a regex prefix so all methods beginning with the selected name will match.
Configure the extension in VS Code settings:
phpunit-test-runner.phpunitPath: Path to PHPUnit executable (default:"php vendor/bin/co-phpunit")phpunit-test-runner.phpunitArgs: Additional PHPUnit arguments (default:"--colors=always")
When you click "▶ Run Test" on a method called testEditMessage in test/Cases/AdminChatTest.php, the extension will run:
php vendor/bin/co-phpunit --colors=always test/Cases/AdminChatTest.php --filter "/^testEditMessage.*/"- Install the extension in VS Code
- Configure your PHPUnit path and arguments in settings if different from defaults
- Open PHP test files and start testing!
- Methods starting with
test:public function testSomething() - Methods with
@testannotation: Any method with/** @test */above it
git clone https://github.com/dickwu/hyperf-phpunit-runner-extension.git
cd hyperf-phpunit-runner-extension
# if you don't have vsce, install it first
npm install -g @vscode/vsce
npm install
vsce package
code --install-extension hyperf-phpunit-runner-*.*.*.vsix # replace *.*.* with your version