如何在单独的进程中运行单个 phpUnit 测试


How to run a single phpUnit test in a separate process?

是否可以在同一进程中运行 phpUnit 测试的测试套件,但确定要在自己的进程中运行的特定测试?

通常我使用

@runTestsInSeparateProcesses
@preserveGlobalState disabled

对于整个测试套件,但我只需要单独运行一种方法,并且我希望在单个进程中运行其余方法的速度提高。

谢谢

正如你在 PHPUnit 手册中看到的,你可以使用 @runInSeparateProcess 标签:

class MyTest extends PHPUnit_Framework_TestCase
{
    /**
    * @runInSeparateProcess
    */
    public function testInSeparateProcess()
    {
        // ...
    }
}