Hi,
How to configure the test explorer to run phpunit in a docker container?
I have been able to configure XDebug and it is working extremely well, I am now just missing this feature to retire phpstorm :)
Thank you in advance for your help!
Hi,
How to configure the test explorer to run phpunit in a docker container?
I have been able to configure XDebug and it is working extremely well, I am now just missing this feature to retire phpstorm :)
Thank you in advance for your help!
wiechecprzemyslaw Thanks for the link, but like I said, XDebug is already working :) Now my issue is to be able to run the tests from Test Explorer in the docker container 😅
Ahhh.... sorry, to hot today :D
Hi @gdelazzer ! Actually, this might not be possible yet.
We don't have a launch profile for it (only "listen" would work), and the Test Explorer is still hardcoded for a local php
.
I'll note this as a todo :)
@gdelazzer @wiechecprzemyslaw preparing blog post with the steps; stay tuned!
Check it while it's fresh 😀 https://blog.devsense.com/2022/develop-php-in-docker
@MiloslavBeno I'm still struggling with this setup. I develop on WSL using a docker compose file and a volume mount. Every project has different docker compose configurations and different types of PHP containers in it. Running PHPUnit is a bit of a pain now and I can't seem to get it to work properly from inside VScode.
Using https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer I could let the extension execute PHPUnit inside a custom container like so docker exec {container_name} sh -c.
Would something similar be possible here?
Hello,
Thank you for your input.
The article explains how to run tests if you are developing inside of the container, which basically makes our extension think you are developing locally.
In case you are running VSCode outside of the container we would need to run a command like you've said docker exec {container_name} sh -c
. We do not have such an option right now, but it shouldn't be a problem to create it. I'm making a note to take a look at it soon.
Thanks!
From what I've tried, opening the docker container as a remote workspace directly in VS Code lets you to even run PHPUnit there the same way as it would be locally.
Hey MiloslavBeno I'm running into the the same scenario where I don't want to develop inside my php docker container. I'm looking for a solution where I could do something along the lines of docker exec {container_name} sh -c
so I can make use of the test explorer without having to have my whole vscode inside the container.
Here is how I run php unit tests in docker (laradock) in vscode
settings.json
{
....
"phpunit.command": "docker-compose -f ./../laradock-wmw-es/docker-compose.yml exec --user=laradock -w /var/www/laravel workspace php artisan dusk ${phpunitargs}",
"phpunit.phpunit": "./vendor/bin/phpunit",
"phpunit.paths": {
"${workspaceFolder}": "/var/www/laravel/"
},
....
}
I run php artisan dusk
as it runs both regular tests and dusk tests.