PhpUnit 内联数据提供者

PhpUnit inline DataProvider

有没有办法直接在注解中指定测试参数?像这样:

 /**
 * @dataProvider [[0, 0, 0], [0, 1, 1], [1, 0, 1]]
 */
public function testAdd($a, $b, $expected)
{
    $this->assertEquals($expected, $a + $b);
}

因为当 DataProvider 只对简单数据集使用一次时它会很有用。

您描述的内容已添加到 PHPUnit 4.8 中。

感谢 Sebastian Bergmann,解决方案是使用 @testWith :

 /**
 * @testWith [0, 0, 0]
 *           [0, 1, 1]
 *           [1, 1, 2]
 *           [1, 0, 1]
 */
public function testAdd($a, $b, $c)
{
    $this->assertEquals($c, $a + $b);
}