pest-plugin-drift icon indicating copy to clipboard operation
pest-plugin-drift copied to clipboard

Covers annotations are not converted

Open dshafik opened this issue 1 year ago • 1 comments

If you use e.g. the #[CoversClass(Foo::class)] annotation, then it is not converted to a ->covers() chained call on the test. This means that if you have requireCoverageMetadata="true" in your phpunit.xml config, all tests will fail.

Input

#[CoversClass(Foo::class)]
class MyTest extends TestCase {
    public function testItDoesThing()
    {
        …
    }
}

Actual Output

test('it does thing', function () {
    …
});

And:

 WARN  Tests\Unit\MyTest
  ! it does thing → This test does not define a code coverage target but is expected to do so

Expected Output

test('it does thing', function () {
    …
})->covers(Foo::class);

dshafik avatar May 09 '24 07:05 dshafik