iva*_*bik 10 junit phpunit unit-testing
在JUnit上,您可以使用注释@RunWith(Parameterized.class)多次运行单个单元测试,具有不同的实际和预期结果.我是PHPUnit的新手,所以我想知道实现相同的建议方法(运行一个具有许多实际预期结果的单元测试)?
hek*_*mgl 18
您可以使用所谓的数据提供程序.像这样:
/**
* @dataProvider providerPersonData
*/
public function testPerson($name, $age) {
// test something ...
}
public function providerPersonData() {
// test with this values
return array(
array('foo', 36),
array('bar', 99),
// ...
);
}
Run Code Online (Sandbox Code Playgroud)
您可以使用@dataProvider注释定义数据提供者.
| 归档时间: |
|
| 查看次数: |
2071 次 |
| 最近记录: |