How to set a test function without prefix/annotation

Viewed 92

In phpunit, you can set a test method using de prefix test on the name, or using the annotation /* @test */.

I wonder configure all public methods as test. How can do it?


<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

class MyTest extends TestCase
{
    
    public function a_test_without_prefix_or_annotation(): void
    {
        // ...
    }

    private function some_method_that_will_not_executed_as_a_test(): void
    {
       // ...
    }
}

1 Answers

No, this is not possible. A method must either have the "test" prefix or be annotated with /** @test */.

Related