Skip to content

Commit 5aa4447

Browse files
committed
docs: rename README files to uppercase convention
1 parent a7f038c commit 5aa4447

File tree

2 files changed

+97
-155
lines changed

2 files changed

+97
-155
lines changed

README.md

Lines changed: 96 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,91 @@
1-
# PHPUnit & Pest Test Explorer
1+
# PHPUnit & Pest Test Explorer for VS Code
22

3-
[![version](https://img.shields.io/vscode-marketplace/v/recca0120.vscode-phpunit.svg?style=flat-square&label=vscode%20marketplace)](https://marketplace.visualstudio.com/items?itemName=recca0120.vscode-phpunit)
4-
[![downloads](https://img.shields.io/vscode-marketplace/d/recca0120.vscode-phpunit.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=recca0120.vscode-phpunit)
3+
[![Version](https://img.shields.io/vscode-marketplace/v/recca0120.vscode-phpunit.svg?style=flat-square&label=vscode%20marketplace)](https://marketplace.visualstudio.com/items?itemName=recca0120.vscode-phpunit)
4+
[![Downloads](https://img.shields.io/vscode-marketplace/d/recca0120.vscode-phpunit.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=recca0120.vscode-phpunit)
55

6-
Run your PHPUnit OR Pest tests in Node using the Test Explorer UI.
6+
[繁體中文](README.zh-TW.md)
7+
8+
Run PHPUnit and Pest tests directly in VS Code with the native Test Explorer UI. Supports Docker, SSH, and remote environments with Xdebug step-debugging.
79

810
![PHPUnit](img/phpunit.gif)
911

10-
![PEST](img/pest.png)
12+
![Pest](img/pest.png)
1113

1214
## Features
1315

14-
- Shows a Test Explorer in the Test view in VS Code's sidebar with all detected tests and suites and their state
15-
- Shows a failed test's log when the test is selected in the explorer
16-
- Lets you choose test suites or individual tests in the explorer that should be run automatically after each file
17-
change
16+
- Discovers and displays all PHPUnit / Pest tests in the Test Explorer sidebar
17+
- Run or debug individual tests, files, suites, or the entire project
18+
- Colored output channel with syntax-highlighted results and embedded PHP source snippets
19+
- Clickable file links in error stack traces
20+
- Supports PHPUnit 7 – 12 and Pest 2 – 3
21+
- Supports ParaTest for parallel execution
22+
- Works in Docker, SSH, and other remote environments via custom commands
23+
- Xdebug integration for step-by-step debugging
24+
- Continuous test runs on file changes
1825

19-
## Extension Settings
26+
## Commands
2027

21-
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
28+
| Command | Title | Default Keybinding |
29+
|---|---|---|
30+
| `phpunit.reload` | Reload tests ||
31+
| `phpunit.run-all` | Run all tests | `Cmd+T Cmd+S` |
32+
| `phpunit.run-file` | Run tests in current file | `Cmd+T Cmd+F` |
33+
| `phpunit.run-test-at-cursor` | Run test at cursor | `Cmd+T Cmd+T` |
34+
| `phpunit.run-by-group` | Run tests by group ||
35+
| `phpunit.rerun` | Repeat last test run | `Cmd+T Cmd+L` |
2236

23-
This extension contributes the following settings:
37+
## Settings
2438

25-
- `phpunit.php`: Absolute path to php. Fallback to global php if it exists on the command line.
26-
- `phpunit.phpunit`: Path to phpunit. Can be the phpunit file or phpunit.phar.\n\nAutomatically finds it in common
27-
places:\n - Composer vendor directory\n - phpunit.phar in your project\n - phpunit (or phpunit.bat for windows)
28-
globally on the command line
29-
- `phpunit.command`: Custom command to run. Ex: `docker exec -t container_name`.
30-
- `phpunit.args`: Any phpunit args (phpunit --help) E.g. --configuration ./phpunit.xml.dist
31-
- `phpunit.environment`: Set environment variables before running the phpunit command, Ex: { "XDEBUG_MODE": "coverage" }
32-
or "XDEBUG_MODE=coverage"
33-
- `phpunit.clearOutputOnRun`: True will clear the output when we run a new test. False will leave the output after every
34-
test.
35-
- `phpunit.showAfterExecution`: Specify if the test report will automatically be shown after execution
36-
- `phpunit.debuggerConfig`: Specify the debugger launch configuration
39+
All settings are under the `phpunit.*` namespace. Add them to `.vscode/settings.json`.
3740

38-
## Commands
41+
| Setting | Type | Default | Description |
42+
|---|---|---|---|
43+
| `phpunit.php` | `string` | `"php"` | Path to the PHP binary. Falls back to the global `php` on PATH. |
44+
| `phpunit.phpunit` | `string` | `"vendor/bin/phpunit"` | Path to PHPUnit or Pest binary. Auto-detected from `vendor/bin`, project root, or global PATH. |
45+
| `phpunit.command` | `string` | `"${php}" ${phpargs} "${phpunit}" ${phpunitargs}` | Custom command template. Available variables: `${php}`, `${phpargs}`, `${phpunit}`, `${phpunitargs}`, `${phpunitxml}`, `${cwd}`. |
46+
| `phpunit.args` | `string[]` | `[]` | Extra arguments passed to PHPUnit (e.g. `["-c", "phpunit.xml.dist"]`). |
47+
| `phpunit.paths` | `object` || Path mappings for remote environments (e.g. `{ "${workspaceFolder}": "/app" }`). |
48+
| `phpunit.environment` | `object` || Environment variables set before running (e.g. `{ "XDEBUG_MODE": "coverage" }`). |
49+
| `phpunit.clearOutputOnRun` | `boolean` | `true` | Clear the output channel before each run. |
50+
| `phpunit.showAfterExecution` | `string` | `"onFailure"` | When to show the output channel: `"always"`, `"onFailure"`, or `"never"`. |
51+
| `phpunit.debuggerConfig` | `string` || Name of a `launch.json` configuration to use when debugging tests. |
52+
| `phpunit.xdebugPort` | `integer` | `0` | Port for Xdebug communication. `0` uses a random port. |
3953

40-
The following commands are available in VS Code's command palette, use the ID to add them to your keyboard shortcuts:
54+
## Configuration Examples
4155

42-
- `phpunit.reload`: PHPUnit: Reload tests
43-
- `phpunit.run-all`: PHPUnit: Run all tests
44-
- `phpunit.run-file`: PHPUnit: Run tests in current file
45-
- `phpunit.run-test-at-cursor`: PHPUnit: Run the test at the current cursor position
46-
- `phpunit.rerun`: PHPUnit: Repeat the last test run
56+
### Basic
4757

48-
## Configuration
58+
PHPUnit and Pest are auto-detected. No configuration needed in most cases.
4959

50-
### [Laravel Artisan](https://laravel.com/docs/12.x/artisan)
60+
To use Pest explicitly:
5161

5262
```jsonc
5363
{
54-
"phpunit.phpunit": "artisan test"
64+
"phpunit.phpunit": "vendor/bin/pest"
5565
}
5666
```
5767

58-
### [Laravel Sail](https://laravel.com/docs/12.x/sail)
68+
### Laravel Artisan
5969

6070
```jsonc
6171
{
62-
"phpunit.command": "docker compose exec -u sail laravel.test ${php} ${phpargs} ${phpunit} ${phpunitargs}",
63-
"phpunit.phpunit": "artisan test",
64-
"phpunit.paths": {
65-
"${workspaceFolder}": "/var/www/html",
66-
}
72+
"phpunit.phpunit": "artisan test"
6773
}
6874
```
6975

70-
### [Pest](https://pestphp.com/)
76+
### Laravel Sail
7177

7278
```jsonc
7379
{
74-
"phpunit.phpunit": "vendor/bin/pest"
80+
"phpunit.command": "docker compose exec -u sail laravel.test ${php} ${phpargs} ${phpunit} ${phpunitargs}",
81+
"phpunit.phpunit": "artisan test",
82+
"phpunit.paths": {
83+
"${workspaceFolder}": "/var/www/html"
84+
}
7585
}
7686
```
7787

78-
### [ParaTest](https://github.com/paratestphp/paratest)
88+
### ParaTest
7989

8090
```jsonc
8191
{
@@ -88,164 +98,96 @@ The following commands are available in VS Code's command palette, use the ID to
8898
```jsonc
8999
{
90100
"phpunit.command": "docker exec -t [container_id] /bin/sh -c \"${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
91-
"phpunit.php": "php",
92-
"phpunit.phpunit": "vendor/bin/phpunit",
93-
"phpunit.args": [
94-
"-c",
95-
"phpunit.xml"
96-
],
97101
"phpunit.paths": {
98-
"${workspaceFolder}": "/app",
99-
},
102+
"${workspaceFolder}": "/app"
103+
}
100104
}
101105
```
102106

107+
Or with `docker run`:
108+
103109
```jsonc
104110
{
105111
"phpunit.command": "docker run --rm -t -v ${PWD}:/app -w /app php:latest ${php} ${phpargs} ${phpunit} ${phpunitargs}",
106-
"phpunit.php": "php",
107-
"phpunit.phpunit": "vendor/bin/phpunit",
108-
"phpunit.args": [
109-
"-c",
110-
"phpunit.xml"
111-
],
112112
"phpunit.paths": {
113-
"${workspaceFolder}": "/app",
114-
},
113+
"${workspaceFolder}": "/app"
114+
}
115115
}
116116
```
117117

118-
### Docker & Pest
118+
### SSH
119119

120120
```jsonc
121121
{
122-
"phpunit.command": "docker exec -t [container_id] /bin/sh -c \"${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
123-
"phpunit.php": "php",
124-
"phpunit.phpunit": "vendor/bin/pest",
125-
"phpunit.args": [
126-
"-c",
127-
"phpunit.xml"
128-
],
122+
"phpunit.command": "ssh user@host \"cd /app; ${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
129123
"phpunit.paths": {
130-
"${workspaceFolder}": "/app",
131-
},
124+
"${workspaceFolder}": "/app"
125+
}
132126
}
133127
```
134128

129+
### DDEV
130+
135131
```jsonc
136132
{
137-
"phpunit.command": "docker run --rm -t -v ${PWD}:/app -w /app php:latest ${php} ${phpargs} ${phpunit} ${phpunitargs}",
138-
"phpunit.php": "php",
139-
"phpunit.phpunit": "vendor/bin/pest",
140-
"phpunit.args": [
141-
"-c",
142-
"phpunit.xml"
143-
],
144-
"phpunit.paths": {
145-
"${workspaceFolder}": "/app",
146-
},
133+
"phpunit.command": "ddev exec ${php} ${phpargs} ${phpunit} ${phpunitargs}"
147134
}
148135
```
149136

150-
### SSH
137+
## Debugging with Xdebug
138+
139+
1. Create a launch configuration in `.vscode/launch.json`:
151140

152141
```jsonc
153142
{
154-
"phpunit.command": "ssh -i dockerfiles/pest/id_rsa -p 2222 root@localhost -o StrictHostKeyChecking=no \"cd /app; ${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
155-
"phpunit.php": "php",
156-
"phpunit.phpunit": "vendor/bin/phpunit",
157-
"phpunit.args": [
158-
"-c",
159-
"phpunit.xml"
160-
],
161-
"phpunit.paths": {
162-
"${workspaceFolder}": "/app",
163-
}
143+
"version": "0.2.0",
144+
"configurations": [
145+
{
146+
"name": "Listen for Xdebug",
147+
"type": "php",
148+
"request": "launch",
149+
"port": 9003,
150+
"pathMappings": {
151+
"/var/www": "${workspaceRoot}"
152+
}
153+
}
154+
]
164155
}
165156
```
166157

167-
### SSH & Pest
158+
2. Point the extension to that configuration:
168159

169160
```jsonc
170161
{
171-
"phpunit.command": "ssh -i dockerfiles/pest/id_rsa -p 2222 root@localhost -o StrictHostKeyChecking=no \"cd /app; ${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
172-
"phpunit.php": "php",
173-
"phpunit.phpunit": "vendor/bin/pest",
174-
"phpunit.args": [
175-
"-c",
176-
"phpunit.xml"
177-
],
178-
"phpunit.paths": {
179-
"${workspaceFolder}": "/app",
180-
}
162+
"phpunit.debuggerConfig": "Listen for Xdebug"
181163
}
182164
```
183165

184-
## Troubleshooting
185-
186-
### PHPUnit path mapping not working
187-
188-
**Problem:**
189-
Path mapping with `${workspaceFolder}` does not work as expected.
190-
Example:
166+
If your Xdebug is configured with `xdebug.start_with_request=trigger`, add the trigger variable:
191167

192-
```json
168+
```jsonc
193169
{
194-
"phpunit.paths": {
195-
"${workspaceFolder}": "/app"
196-
}
170+
"phpunit.command": "docker compose exec -e XDEBUG_TRIGGER=VSCODE app bash -c \"${php} ${phpargs} ${phpunit} ${phpunitargs}\"",
171+
"phpunit.debuggerConfig": "Listen for Xdebug"
197172
}
198173
```
199174

200-
Solution:
201-
Replace ${workspaceFolder} with the actual project path.
202-
For example:
175+
Then use the **Debug Test** button in the Test Explorer.
203176

204-
```json
205-
{
206-
"phpunit.paths": {
207-
"/myproject": "/app"
208-
}
209-
}
210-
```
177+
## Troubleshooting
211178

212-
### Running test with XDEBUG_TRIGGER env
179+
### `${workspaceFolder}` not resolving in path mappings
213180

214-
When you have a PHP Xdebug launch configuration like this below:
181+
Replace `${workspaceFolder}` with the actual absolute path:
215182

216183
```jsonc
217184
{
218-
"version": "0.2.0",
219-
"configurations": [
220-
{
221-
"name": "Listen for Xdebug",
222-
"type": "php",
223-
"request": "launch",
224-
"port": 9003,
225-
"pathMappings": {
226-
"/var/www": "${workspaceRoot}"
227-
},
228-
"runtimeArgs": [
229-
"-dxdebug.mode=debug,develop",
230-
]
231-
}
232-
]
185+
"phpunit.paths": {
186+
"/home/user/myproject": "/app"
187+
}
233188
}
234189
```
235190

236-
and you are using docker compose, setup the extension with the configuration below to enable debug if your `xdebug.ini`
237-
configuration has `xdebug.start_with_request=trigger`:
238-
239-
```jsonc
240-
{
241-
"phpunit.command": "docker compose -f docker-compose.yml -f docker-compose.test.yml -f docker-compose.test.override.yml exec -e 'XDEBUG_TRIGGER=VSCODE' app bash -c",// "app" is the container name in the docker-compose.yml
242-
"phpunit.phpunit": "/var/www/artisan test --without-tty", //link to the Laravel artisan file in the container which is used to run the test
243-
"phpunit.paths": {
244-
"${workspaceFolder}": "/var/www"
245-
},
246-
"phpunit.debuggerConfig": "Listen for Xdebug",// This name of the launch configuration for PHP XDEBUG extension
247-
}
248-
```
191+
## License
249192

250-
Then you can run the test with the "Debug Test" icon button. You can also run the test using the "Run Test" icon but you
251-
should have already started the Xdebug session from VSCode Debugger before running the test.
193+
[MIT](LICENSE.md)

readme.zh-TW.md renamed to README.zh-TW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Version](https://img.shields.io/vscode-marketplace/v/recca0120.vscode-phpunit.svg?style=flat-square&label=vscode%20marketplace)](https://marketplace.visualstudio.com/items?itemName=recca0120.vscode-phpunit)
44
[![Downloads](https://img.shields.io/vscode-marketplace/d/recca0120.vscode-phpunit.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=recca0120.vscode-phpunit)
55

6-
[English](readme.md)
6+
[English](README.md)
77

88
在 VS Code 中使用原生 Test Explorer 執行 PHPUnit 和 Pest 測試。支援 Docker、SSH 等遠端環境,並可搭配 Xdebug 進行逐步偵錯。
99

0 commit comments

Comments
 (0)