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

abinshoby created an issue. See original summary.

cilefen’s picture

Category: Bug report » Support request
Priority: Major » Normal

Not having code coverage isn't even close to a major priority bug.

longwave’s picture

Yes, 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.

cilefen’s picture

Status: Active » Fixed
abinshoby’s picture

Thanks 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.

cilefen’s picture

Open 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.