Coverage for class/interface/trait itself is not measured
mvorisek opened this issue · 4 comments
mvorisek commented
| Q | A |
|---|---|
| php-code-coverage version | 10.1.11 |
| PHP version | 8.3.0 |
| Driver | Xdebug |
| PCOV version (if used) | n/a |
| Xdebug version (if used) | 3.3.1 |
| Installation Method | Composer |
| Usage Method | PHPUnit |
| PHPUnit version (if used) | 10.5.9 |
repro code:
<?php
class X
{
}
generates zero coverage lines (which makes the file completely ignored for CodeCov).
I would expect coverage to be emit on the l3 (l9 in the screenshot below) (ie. the line where the class starts). The meaning is if the class has been included or not.
sebastianbergmann commented
This is by design: a class declaration is not considered executable.
mvorisek commented
@sebastianbergmann may I know why? Here is a usecase: https://github.com/atk4/ui/blob/5.0.0/src/Exception/ExitApplicationError.php - without this issue, we cannot tell if the class is used/covered or not.
sebastianbergmann commented
Declarations are not relevant at runtime.
