如何在没有 prefix/annotation 的情况下设置测试功能

How to set a test function without prefix/annotation

在 phpunit 中,您可以在名称上使用 de 前缀 test 或使用注释 /* @test */.

来设置测试方法

我想知道将所有 public 方法配置为测试。怎么做到的?


<?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
    {
       // ...
    }
}

不,这是不可能的。方法必须具有“test”前缀或使用 /** @test */.

注释