我有一个看起来像这样的 PHPUnit 测试:
/**
* @dataProvider provideSomeStuff
*/
public function testSomething($a, $b, $c)
{
...
}
/**
* @dataProvider provideSomeStuff
* @depends testSomething
*/
public function testSomethingElse($a, $b, $c)
{
...
}
/**
* @depends testSomething
*/
public function testMoreStuff()
{
...
}
// Several more tests with the exact same setup as testMoreStuff
即使testSomething
成功,所有依赖它的测试都会被跳过。PHPUnit 手册中的一些注释告知测试可以依赖于使用数据提供者的其他测试:
注意
当一个测试从@dataProvider 方法和它@depends 的一个或多个测试接收输入时,来自数据提供者的参数将在来自依赖测试的参数之前。注意
当测试依赖于使用数据提供者的测试时,依赖的测试将在它依赖的测试对至少一个数据集成功时执行。使用数据提供者的测试结果不能注入到依赖测试中。
所以我不知道为什么它会跳过我所有的测试。我已经为此苦苦挣扎了几个小时,有人帮助我。这是完整的测试代码,以防问题不能从上面的伪代码中得出
测试结果截图: