Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[CoversMethod] attribute is not considered for risky test check #5807

Closed
steevanb opened this issue Apr 9, 2024 · 0 comments
Closed

#[CoversMethod] attribute is not considered for risky test check #5807

steevanb opened this issue Apr 9, 2024 · 0 comments
Assignees
Labels
feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata/attributes type/bug Something is broken version/11 Something affects PHPUnit 11

Comments

@steevanb
Copy link

steevanb commented Apr 9, 2024

Q A
PHPUnit version 11.1.1
PHP version 8.3.4
Installation Method Composer

Summary

When i use CoversMethod attribute, PHPUnit do not understand it is a coverage attribute.
If i replace CoversMethod by CoversNothing or CoversClass, coverage error disapear.

Current behavior

CoversMethod do not configure the code coverage.

How to reproduce

#[CoversMethod(ToDelete::class, 'foo')]
final class ToDeleteTest extends TestCase
{
    public function testFoo(): void
    {
        static::assertSame(1, (new ToDelete())->foo());
    }
}

Result:

PHPUnit 11.1.1 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.4
Configuration: /app/config/ci/phpunit.xml

R                                                                   1 / 1 (100%)

Time: 00:00.003, Memory: 4.00 MB

There was 1 risky test:

1) App\Tests\ToDeleteTest::testFoo
This test does not define a code coverage target but is expected to do so

/app/tests/ToDeleteTest.php:17

OK, but there were issues!
Tests: 1, Assertions: 1, Risky: 1.

Expected behavior

Code coverage should be configured with this attribute, right?

@steevanb steevanb added the type/bug Something is broken label Apr 9, 2024
@sebastianbergmann sebastianbergmann self-assigned this Apr 10, 2024
@sebastianbergmann sebastianbergmann added feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata/attributes version/11 Something affects PHPUnit 11 labels Apr 10, 2024
@sebastianbergmann sebastianbergmann changed the title #[CoversMethod()]: This test does not define a code coverage target but is expected to do so #[CoversMethod] attribute is not considered for risky test check Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/code-coverage Issues related to code coverage (but not php-code-coverage) feature/metadata/attributes type/bug Something is broken version/11 Something affects PHPUnit 11
Projects
None yet
Development

No branches or pull requests

2 participants