W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
除了實(shí)現(xiàn)一個(gè)方法并將之與 ?@dataProvider? 聯(lián)用外,你也可以用 ?@testWith? 標(biāo)注來(lái)定義數(shù)據(jù)集。
數(shù)據(jù)集由一個(gè)或多個(gè)元素組成。要定義具有多個(gè)元素的數(shù)據(jù)集,每個(gè)元素都要定義在單獨(dú)一行中。數(shù)據(jù)集的每個(gè)元素都必須是以 JSON 格式定義的數(shù)組。
/**
* @testWith ["test", 4]
* ["longer-string", 13]
*/
public function testStringLength(string $input, int $expectedLength): void
{
$this->assertSame($expectedLength, strlen($input));
}
以 JSON 格式表示的對(duì)象會(huì)轉(zhuǎn)換為關(guān)聯(lián)數(shù)組。
/**
* @testWith [{"day": "monday", "conditions": "sunny"}, ["day", "conditions"]]
*/
public function testArrayKeys(array $array, array $keys): void
{
$this->assertSame($keys, array_keys($array));
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: