我正在使用 Codeception 进行 WebServices 测试,这是我的代码:
//Making first query for getting needed parameter
$I->wantTo('Make something');
$I->sendPOST($this->route, [
'token' => Fixtures::get('token'),
'id' => Fixtures::get('some_id')
]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('"error_message"');
//Then I get what I need with regexp
if (preg_match('/^.*\s(?<value_i_need>\d+)\.$/', $I->grabDataFromResponseByJsonPath('$.status.error_message')[0], $matches)) {
$I->sendPOST($this->route, [
'token' => Fixtures::get('token'),
'id' => Fixtures::get('some_id')
]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('"something"');
$I->seeResponseContains('"something_else"');
} else {
//And if I don't get needed parameter with regular expression, here I have to force test fail
}
有人知道如何强制测试失败吗?
提前致谢!
最佳答案
您可以对您的 actor 使用失败操作。即
$I->fail('this test fails... just because');
关于php - 如何在 Codeception 中强制测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32166703/