2015-11-03 75 views
0

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

{ 
"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 

回答

0

让你有测试设置?

var data = JSON.parse(responseBody); 
    tests["Pass this case"] = data.id === 11f345f7-9f12-58fb-099d-27f11233cee7; 
0

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

检查此#298