php - 如何在 Codeception 中强制测试失败

标签 php testing codeception

我正在使用 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/

相关文章:

php fsockopen 不工作

php - 如何在浏览器中显示大约 1000 张每个 30 kb 的图像?

java - 如何测试直接在外部 API 上运行的 Java 应用程序

eclipse - 从 pom.xml 设置事件 Spring 配置文件并与 IDE 集成

cucumber - 德语中包含 Gherkin 关键字的 Codeception

codeception - I.click()-CodeceptJS 中的选择器 - 如何找到具有特定 innerHTML 的第一个按钮

php - 是否可以将 Codeception 的功能/验收配置 URL 存储在存储库外部?

php - fatal error : Allowed memory size of 1610612736 bytes exhausted but already allocated 1. 75G

php - 适用于 Windows 的 Composer 安装-

javascript - Jasmine 不能监视事件处理程序?