-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Q | A |
---|---|
php-code-coverage version | 10.1.1 |
PHP version | 8.2.5 |
Driver | Xdebug |
Xdebug version (if used) | 3.2.1 |
Installation Method | irrelevant, same result in both cases |
Usage Method | PHPUnit |
PHPUnit version (if used) | 10.1.2 |
Given
- A
phpunit.xml.dist
config file which includes theforceCoversAnnotation="true"
(PHPUnit 9.x) orrequireCoverageMetadata="true"
(PHPUnit 10.x) directive; - And a test which has a
@covers
tag for a method which doesn't exist.
I'd expect
That no code coverage would be recorded for the test with the incorrect @covers
tag, along the same lines as if the test had a @covers
tag for a method which wasn't run during the test.
And if the test had multiple @covers
tags, I'd expect code coverage only to be recorded for the valid tags.
What happened instead
Coverage was recorded as if forceCoversAnnotation
/requireCoverageMetadata
was set to false
, i.e. all code which was run during the test now shows as covered, even though there are no tests with the appropriate @covers
tags for that code.
Reproduction scenario
See the individual commits in the https://github.com/jrfnl/bug-report-reproduction-scenarios/tree/php-code-coverage/997-wrong-covers-tag-wrong-coverage branch.
Each commit includes the coverage reports (text summary in the commit message, HTML + Clover reports in the actual commits).