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.
If we use
@testannotations to declare test methods, you may forgot to add the annotation, leading to the test method being silently ignored and not executed.We could make fixer to make sure public method starting with "should" (which is our convention for test method names) have the
@testannotation. (This must apply only to PHPUnit test files, ie. files having "Test.php" suffix).Also make sure we cover case when
@testannotation 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.