Closed georgmaisser closed 1 year ago
Hi @georgmaisser,
XDebug
? Ref: README.HTH, Matteo
Ok, this is obvious, but while I can debug via Chrome, I can't do it when triggering behat & unit tests. There must be something else to add to listen to these tests... thank you!
Hi @georgmaisser,
There must be something else to add to listen to these tests... thank you!
Let me understand:
Behat runs give you the possibility to collect the screenshots when failing and you could replicate the scenario locally by exposing the web server as you're probably already doing i.e. AFAIK you can't debug remotely a Behat test. https://moodledev.io/general/development/tools/behat/running#the-tests-are-failing-and-the-error-message-is-completely-useless could be of some help. In the past someone already try to post a request in the Community unfortunately w/o any reply.
PHPUnit should be executed starting from your IDE to allow XDebug to be activated: https://docs.moodle.org/dev/Setting_up_PhpStorm#Debugging_with_Xdebug_with_docker_containers could be of some help together with the previous link from the README.
Disclaimer: I do not use any remote debug option while running the tests.
HTH, Matteo
Thank you so much for your detailed explanations!
Just for context: I run the docker container locally and use VSCode to develop, exactly like everything is explained in the readme.
The important part for me are the phpUnit tests. Thanks to your explanation I did the following. I added this to the base.yml:
XDEBUG_CONFIG: idekey=VSCODE remote_enable=1 remote_mode=req remote_port=9003 remote_host=host.docker.internal remote_connect_back=0 PHP_IDE_CONFIG: serverName=moodle-local
After reinstalling xdebug as usual within the container, the Breakpoints actually worked! That was the missing piece for me!
As for the behat: You are right of course that one can replicate, but sometimes there are situations where it would be nice to actually see which value is used in the behat test. With "I wait for "100" seconds and Developer Tools in Chrome within VNC, a lot is possible, but I once had a modal failing only within the behat environment and it was very hard to debug.
But your answer helped a lot to solve most of my problem, so thank you very much!
Thanks @scara and @georgmaisser ! If there is anything that can be added to the instructions to make it easier, feel free to suggest it in some PR!
Ciao :-)
Hi, is there any chance to use breakpoints when running the phpUnit (or Behat) tests in the container? This would help so much! I couldn't find out a good way of debugging those tests with the docker setup.