所以问题是:有没有办法直接在注释中指定测试参数?像这样的东西:
/**
* @dataProvider [[0, 0, 0], [0, 1, 1], [1, 0, 1]]
*/
public function testAdd($a, $b, $expected)
{
$this->assertEquals($expected, $a + $b);
}
Run Code Online (Sandbox Code Playgroud)
因为如果DataProvider仅使用简单数据集一次就很有用.
感谢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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
347 次 |
| 最近记录: |