Codeception - API测试响应错误

时间:2014-10-17 07:49:51

标签: codeception

我用fiddler向服务器发送请求,它发送响应

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

我想用代码检查

    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'));
    ?>

行参见Response包含Json错误

1 个答案:

答案 0 :(得分:0)

如果你用--debug这样运行怎么办?它是否提供了什么问题的任何细节?

codecept.phar run --debug