Closed yakov255 closed 1 month ago
Hi @yakov255
I can't reproduce this, and at the moment I can't see how the scenario you've outlined could happen for a couple of reasons:
1) Although the param is not passed in on that line, that's only used as a dry-run to check that a driver can be found. The actual init that's used when running the suite is a couple of lines later on https://github.com/dvdoug/behat-code-coverage/blob/master/src/Extension.php#L200, where it is indeed set
2) If both pcov and Xdebug are available, pcov is the one that's used, not Xdebug. That's done over at https://github.com/sebastianbergmann/php-code-coverage/blob/main/src/Driver/Selector.php#L25 and it's pretty explicit
Are you able to create a repo with a full example that I can download and run to see this behaviour?
Hi @dvdoug!
I make repository for reproduce bug: behat-pcov-reproduce-bug
And while I was creating a repository for playback, I discovered that the problem is related to the version of the phpunit
package and the phpunit/php-code-coverage
package
I found that my project uses phpunit
9 and the problem is reproducible with this version
However, with phpunit
versions 10 and 11, the code coverage report is generated correctly
This is because the package phpunit/php-code-coverage
before version 10 used the exception \SebastianBergmann\CodeCoverage\Driver\Xdebug3NotEnabledException
Which is not caught by extension
And since version 10, the package has been using \SebastianBergmann\CodeCoverage\Driver\XdebugNotEnabledException
As a result, I suggest:
Respect the branchAndPathCoverage
flag as I originally suggested
(do not call `forLineAndPathCoverage' if flag is set)
Add the exception Xdebug3NotEnabledException
to the initCodeCoverage
method
This fix compatibility with phpunit 9
Or we can also go the other way:
Add a minimal dependency on phpunit/php-code-coverage
to version 10
(now "phpunit/php-code-coverage": "^9.2.16||^10.0",
)
Thanks, I'll take a look
I have both Xdebug and Pcov installed And i want to use Pcov for coverage generation In my setup xdebug configured to not start with each request
in my behat.yml i have disabled branch and path coverage by set:
But behat-code-coverage always trying to init xdebug for coverage
this occurs because in source code in file
\DVDoug\Behat\CodeCoverage\Extension
config variable$branchPathConfig
not passed to\DVDoug\Behat\CodeCoverage\Extension::initCodeCoverage
methodif i do manual change that line - evething statrs works as excepcted: code coverage working with xdebug
Can we fix this in code?