您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit数据供给器的错误数据定位方式
发布时间:2021-09-13 10:55:39编辑:雪饮阅读()
像我们上篇中DataTest.php:
use PHPUnit\Framework\TestCase;
final class DataTest extends TestCase
{
/**
* @dataProvider additionProvider
*/
public function testAdd(int $a, int $b, int $expected): void
{
$this->assertSame($expected, $a + $b);
}
public function additionProvider(): array
{
return [
[0, 0, 0],
[0, 1, 1],
[1, 0, 1],
[1, 1, 3]
];
}
}
像是这样,那么运行结果中,错误定位又到索引2上面了
use PHPUnit\Framework\TestCase;
final class DataTest extends TestCase
{
/**
* @dataProvider additionProvider
*/
public function testAdd(int $a, int $b, int $expected): void
{
$this->assertSame($expected, $a + $b);
}
public function additionProvider(): array
{
return [
[0, 0, 0],
[0, 1, 1],
[1, 1, 3],
[1, 0, 1]
];
}
}
关键字词:phpunit,数据供给器,错误定位,索引
上一篇:phpunit数据供给器