1

嗨,我正在通过邮递员测试 API,我想自动化我的测试并下载了 newman。现在我在邮递员中使用的请求已作为一个集合导出,并通过 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

4 回答 4

0

npm 安装邮递员

npm 安装纽曼

npm install newman-reporter-html

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

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

于 2019-01-18T17:06:43.223 回答
0

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

检查这个#298

于 2015-11-25T09:12:37.250 回答
0

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

$ newman run <path of you collection>
于 2018-08-14T07:18:39.420 回答
0

你有测试集吗?

    var data = JSON.parse(responseBody);
    tests["Pass this case"] = data.id === 11f345f7-9f12-58fb-099d-27f11233cee7;
于 2015-11-07T01:25:47.513 回答