W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
測試方法可以接受任意參數(shù)。這些參數(shù)由一個或多個數(shù)據(jù)供給器方法(在使用返回數(shù)組的數(shù)組的數(shù)據(jù)供給器中,是 ?provider()
? 方法)提供。用 ?@dataProvider
? 標(biāo)注來指定要使用的數(shù)據(jù)供給器方法。
<?php declare(strict_types=1);
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]
];
}
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: