【问题标题】:Codeception - API test responce errorCodeception - API 测试响应错误
【发布时间】:2014-10-17 07:49:51
【问题描述】:

我用提琴手向服务器发送请求,它发送响应

Fiddler url: http://api.demo.loc/lc/
header:User-Agent: Fiddler
Host: api.demo.loc
Content-Type: application/x-www-form-urlencoded
Content-Length: 49
Request body: m=stt&l=2&n=5&news_version=2

我想用 codeception 检查这个

    I wrote config like this:
    class_name: ApiGuy
    modules:
          enabled: [PhpBrowser, REST, ApiHelper]
          config:
                PhpBrowser:
                      url: http://api.demo.loc/lc/
                REST:
                      url: http://api.demo.loc/lc/
And my code:
    <?php
    $I = new ApiGuy($scenario);
    $I->wantTo('STEP 1');
    $I->haveHttpHeader('User-Agent: Codeception', 'Host: api.demo.loc');
    $I->haveHttpHeader('Content-Type: application/x-www-form-urlencoded','Content-Length: 49');

    // get a succesful response 
    $I->sendPOST('', array('m' => 'stt','l' => '2', 'n' => '5', 'news_version' => '2'));
    $I->seeResponseCodeIs(200);
    $I->seeResponseIsJson();
    $I->seeResponseContainsJson(array('result' => 'success'));
    ?>

行 seeResponseContainsJson 错误

【问题讨论】:

    标签: codeception


    【解决方案1】:

    如果你像这样使用 --debug 运行它会怎样?它是否提供了任何问题的详细信息?

    codecept.phar run --debug
    

    【讨论】:

    • 也可以在命令末尾抛出--steps,查看测试过程中的每一步。
    猜你喜欢
    • 2014-04-23
    • 2015-08-14
    • 2014-08-17
    • 2018-12-27
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多