Incorrect code coverage metadata does not prevent code coverage data from being collected #5351
Labels
event/code-sprint/2024-03
PHPUnit Code Sprint: March 2024
feature/code-coverage
Issues related to code coverage (but not php-code-coverage)
feature/metadata
Issues related to attributes and annotations
type/bug
Something is broken
Given
phpunit.xml.dist
config file which includes theforceCoversAnnotation="true"
(PHPUnit 9.x) orrequireCoverageMetadata="true"
(PHPUnit 10.x) directive;@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 tofalse
, 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).
The text was updated successfully, but these errors were encountered: