//variable
private $client = array(
"title" => "Ing.",
"name" => "Name",
"surname" => "Surname",
"id_number" => "123456789"
);
public function createClient($client)
{
//creating client
$I->sendPOST('.../api/admin/client', $client);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
//from another get API function I verify data from API resonse with data from variable input
$I->getClient();
$I->assertEquals($data['name'], $this->client['name']);
$I->assertEquals($data['surname'], $this->client['surname']);
$I->assertEquals($data['title'], $this->client['title']);
$I->assertEquals($data['id_number'], $this->client['id_number']);
}
我需要为每次测试运行创建新的客户端(使用新的"名称","姓氏"和#34; id_number")。 所以我需要以某种方式生成例如" Datafactory"可变数据并将它们用于一次测试。 对于另一次运行,我需要不同的数据。
答案 0 :(得分:0)
Codeception具有一些允许您这样做的功能。您可以设置data factory来为您生成这些对象。因为它使用factory muffin和faker为您提供的对象创建值,所以每次数据都会不同。
我在答案的文本中链接了文档。您还可以查看有关工厂松饼的this codeception blog entry,它用于在代码中实现数据工厂。