Problem/Motivation
Browser Test is not giving any code coverage for the custom modules. I have used XDebug 3.1.5 with PHPUnit 9.5.20. However, the code coverage for the custom module is showing incorrectly as 0%. Please, anyone, tell me how to get the code coverage for the custom modules.
Is it because Browser Test runs the test cases on another instance?
Comments
Comment #2
cilefen commentedNot having code coverage isn't even close to a major priority bug.
Comment #3
longwaveYes, it's because functional tests make real HTTP requests to an instance of the site, and the code coverage information for those requests is not recorded correctly by the calling test.
I am not sure if there is an issue somewhere to try and solve this, but I don't think it's straightforward to fix. I am also not sure that functional tests are a good indicator of code coverage, as there is a lot of code executed in a functional test that isn't strictly part of the thing being tested.
Comment #4
cilefen commentedComment #5
abinshoby commentedThanks a lot @longwave. @cilefen I think it would be better if this is included as a new feature in the upcoming releases of PHPUnit since a lot of standard projects require code coverage to be uploaded.
Comment #6
cilefen commentedOpen a feature request if none exists. I know of no way to implement it so people will have to be inventive.
PHPUnit is a separate project from Drupal but I think any implementation here would be inside Drupal.