Skip to content

Make sure test methods have @test annotation #26

Open
@OndraM

Description

@OndraM

If we use @test annotations to declare test methods, you may forgot to add the annotation, leading to the test method being silently ignored and not executed.

    public function shouldDoSomething(): void
    {
         // ...
    }

We could make fixer to make sure public method starting with "should" (which is our convention for test method names) have the @test annotation. (This must apply only to PHPUnit test files, ie. files having "Test.php" suffix).

Also make sure we cover case when @test annotation is wrongly declared (missing space - /**@test */) and thus undetected by PHPUnit as test method.

Note - there is PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer, but it does only unifies the style, even with style set to "annotations", it won't detect methods missing the annotation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions