You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
7
9
8
10

9
11
10
-

12
+

11
13
12
14
## Features
13
15
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
18
25
19
-
## Extension Settings
26
+
## Commands
20
27
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`|
22
36
23
-
This extension contributes the following settings:
37
+
## Settings
24
38
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`.
37
40
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. |
Replace ${workspaceFolder} with the actual project path.
202
-
For example:
175
+
Then use the **Debug Test** button in the Test Explorer.
203
176
204
-
```json
205
-
{
206
-
"phpunit.paths": {
207
-
"/myproject": "/app"
208
-
}
209
-
}
210
-
```
177
+
## Troubleshooting
211
178
212
-
### Running test with XDEBUG_TRIGGER env
179
+
### `${workspaceFolder}` not resolving in path mappings
213
180
214
-
When you have a PHP Xdebug launch configuration like this below:
181
+
Replace `${workspaceFolder}` with the actual absolute path:
215
182
216
183
```jsonc
217
184
{
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
+
}
233
188
}
234
189
```
235
190
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
249
192
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.
0 commit comments