This extension is an enhanced fork-n-remake of Better PHPUnit. The major part of the code is taken from that repository.
Download it from the Marketplace or search for Yet Another PHPUnit in your VSCode editor extension panel.
- Color output!
- SSH support
- Docker support
- Run individual methods
- Run a single file
- Run tests inside a folder
- Run all the tests
- Test failures are displayed in the "Problems" panel for quick access
- CodeLens to run single tests just in one click
Note: this plugin registers "tasks" to run phpunit, not a command like other extensions. This makes it possible to leverage the problem output and color terminal.
- Click
Run test
above the method name
or - Place your cursor on the method name, open the command menu with
cmd+shift+p
and selectYet PHPUnit: Run
- Click
Run class tests
above the class name
or - Right click on the file in the "Explorer" tab on the left sidebar and select
Run File Tests
or - Place your cursor on the class name, open the command menu with
cmd+shift+p
and selectYet PHPUnit: Run
- Right click on the folder in the "Explorer" tab on the left sidebar and select
Run Tests Inside Folder
- Open the command menu:
Cmd+Shift+p
- Select:
Yet PHPUnit: Run All
- Open the command menu:
Cmd+Shift+p
- Select:
Yet PHPUnit: Re-Run Test
Name | Type | Default | Description |
---|---|---|---|
yet-phpunit.commandSuffix |
string | null |
Content (flags, arguments) to be appended to PHPUnit command. For example, if you want to use --testdox this is the correct place. |
yet-phpunit.phpunitBinary |
string | null |
A custom path of PHPUnit binary file. By default it will be auto-discovered from vendor folder. |
yet-phpunit.codelens |
boolean | true |
Set it to false to disable Code Lens, namely the clickable label "Run test" above methods and classes. |
Open your settings (or Workspace settings), switch to JSON and put them like this:
{
"yet-phpunit.commandSuffix": null,
"yet-phpunit.phpunitBinary": null,
"yet-phpunit.codelens": true
}
If you plan to use SSH, take a look also to new VSCode feature: Remote development.
Variables to set up tests over SSH (for VMs like Laravel Homestead):
Name | Type | Default | Description |
---|---|---|---|
yet-phpunit.ssh.enable |
boolean | false |
Set it to true to enable SSH. |
yet-phpunit.ssh.binary |
string | ssh |
Custom SSH agent binary, for example plink.exe (PuTTY ssh). |
yet-phpunit.ssh.host |
string | null |
SSH hostname. |
yet-phpunit.ssh.user |
string | null |
SSH username. |
yet-phpunit.ssh.port |
number | 22 |
SSH port. |
yet-phpunit.ssh.options |
string | null |
Additional SSH options (arguments, flags etc.). |
yet-phpunit.ssh.shellAppend |
string | null |
Stuff to append after the SSH and PHPUnit command. For example, to enable color on Windows this is the right place. |
yet-phpunit.ssh.paths |
object | {} |
The SSH path map. Keys are local (host) paths and values are remote (guest) paths. |
If you use PuTTy, you have to use
plink
as binary file (it's part of with PuTTy)
{
"yet-phpunit.ssh.enable": true,
"yet-phpunit.ssh.binary": "plink.exe",
"yet-phpunit.ssh.host": "host",
"yet-phpunit.ssh.user": "user",
"yet-phpunit.ssh.port": "22",
"yet-phpunit.ssh.options": null,
"yet-phpunit.ssh.shellAppend": null,
"yet-phpunit.ssh.paths": {
"/your/local/path": "/your/remote/path"
}
}
Variables to set up tests in a Docker container:
Name | Type | Default | Description |
---|---|---|---|
yet-phpunit.docker.enable |
boolean | false |
Set it to true to enable Docker support. |
yet-phpunit.docker.command |
string | null |
Command base for Docker, for example docker exec your-container . This is required if you enable Docker. |
yet-phpunit.docker.paths |
object | {} |
The SSH path map. Keys are local (host) paths and values are remote (guest) paths. |
{
"yet-phpunit.docker.enable": true,
"yet-phpunit.docker.command": "docker exec <container-name>",
"yet-phpunit.docker.paths": {
"/your/local/path": "/your/remote/path"
},
}
{
"yet-phpunit.docker.enable": true,
"yet-phpunit.docker.command": "docker-compose run --rm <container-name>",
"yet-phpunit.docker.paths": {
"/your/local/path": "/your/remote/path"
},
}
Tip: if you want to run Docker over a SSH session just should use both options
ssh.enable
anddocker.enable
together.
This is what I'd love to implement in the future:
- Run a single suite tests
- Panel on left sidebar to see suites and available tests
- Re-run failures
- Logo by by FlatIcon is licensed by CC 3.0 BY
- Starting code forked from Better PHPUnit