通过newman测试API

时间:2015-11-03 14:43:59

标签: api postman newman

您好,我正在通过邮递员测试API,我想自动化我的测试并下载了newman。现在我在postman中使用的请求已被导出为一个集合,并通过newman给我一个404 ....任何指针都非常感激。 IP地址已被更改,原因很明显。

{
"id": "11f345f7-9f12-58fb-099d-27f11233cee7",
"name": "GC",
"description": "",
"order": [
    "f7fe3f94-0dd2-6dba-05b9-29ae7e571ed9"
],
"folders": [],
"timestamp": 1446559540652,
"owner": "195242",
"remoteLink": "",
"public": false,
"requests": [
    {
        "id": "f7fe3f94-0dd2-6dba-05b9-29ae7e571ed9",
        "headers": "",
        "url": "http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms",
        "pathVariables": {},
        "preRequestScript": "",
        "method": "GET",
        "collectionId": "11f345f7-9f12-58fb-099d-27f11233cee7",
        "data": [],
        "dataMode": "params",
        "name": "http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms",
        "description": "",
        "descriptionFormat": "html",
        "time": 1446559548262,
        "version": 2,
        "responses": [],
        "tests": "",
        "currentHelper": "normal",
        "helperAttributes": {}
    }
]

}

这是我在纽曼的输出

    $ newman -c GC.json.postman_collection

Iteration 1 of 1
404 218ms http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms

Summary:

Parent                      Pass Count   FailCount
-------------------------------------------------------------
Collection GC                        0           0

Total

                             0           0

4 个答案:

答案 0 :(得分:0)

您是否设置了测试?

public void setCommentText1(String text) {
    String user = "Johny says: ";
    SpannableStringBuilder builder = new SpannableStringBuilder(user + text);
    builder.setSpan(new ForegroundColorSpan(Color.parseColor("#bdbdbd")),
            0, user.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    this.text.setText(builder);
}

答案 1 :(得分:0)

创建Tests并且在测试之前忘记更新您的json集合。

选中此#298

答案 2 :(得分:0)

404表示您正在查找的资源不存在,或者系统找不到所需的数据,您可以尝试使用

$ newman run <path of you collection>

答案 3 :(得分:0)

npm安装邮递员

npm install newman

npm安装newman-reporter-html

https://github.com/shahing/api-automation-tests

在您的目录中运行命令:newman运行test.js