Open
Description
Q | A |
---|---|
PHPUnit version | 9.6.9 |
PHP version | 8.1.20 |
Installation Method | Composer |
Summary
Lately we have changed our docker setup that sets XDEBUG_MODE=debug
(based on .env file) and it broke our execution of tests with code coverage in PHPStorm.
Currently we are able to bypass it by using different PHPStorm run configuration that forces XDEBUG_MODE=coverage
.
Current behavior
PHPUnit outputs a warning:
Warning: XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set
PHPStorm runs the tests with php -dxdebug.mode=coverage /app/vendor/phpunit/phpunit/phpunit
which ensures that xdebug should use coverage value but PHPUnit uses XDEBUG_MODE environment variable with higher priority.
I've checked this by checking xdebug_info
.
debug.php
<?php
xdebug_info();
XDEBUG_MODE=debug php debug.php | grep xdebug.mode
...
xdebug.mode (through XDEBUG_MODE) => debug
XDEBUG_MODE=debug php -dxdebug.mode=coverage debug.php | grep xdebug.mode
...
xdebug.mode (through XDEBUG_MODE) => debug => coverage
I was able to test this in PHPUnit 9 (don't have a project on PHP10), but the code seems same?
Is this expected behavior?
How to reproduce
XDEBUG_MODE=debug php -dxdebug.mode=coverage ./vendor/phpunit/phpunit/phpunit --coverage-text
Expected behavior
Code coverage should be collected.
Thank you for your time!