在documentation for command line integration with Newman中说:
可以将所有测试和请求的结果导出到文件中 后来进入邮递员进行进一步分析。使用JSON 记者和文件名将转轮输出保存到文件中。
我已经尝试过了:
newman run "Echo.postman_collection.json" --reporters cli,json --reporter-json-export outputfile.json
但我没有设法将outputfile.json导入Postman Collection Runner。我总是收到以下错误消息:
runner.js:81831未捕获DataError:无法在'IDBObjectStore'上执行'put':评估对象库的关键路径没有产生值。
我做错了什么?
这是Newman创建的outputfile.json。它实际上具有与Postman Collection Runner中导出的测试运行不同的结构:
{
"collection": {
"info": {
"id": "ef224090-5564-258f-6ca5-68bd578a6c8d",
"name": "Echo",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"event": [],
"variable": [],
"item": [
{
"id": "2cf3e4a4-eb9e-4622-bade-d0536161c97d",
"name": "Delay",
"request": {
"url": "https://postman-echo.com/delay/3",
"method": "GET",
"body": {
"mode": "raw",
"raw": ""
},
"description": {
"content": "",
"type": "text/plain"
}
},
"response": [],
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var responseJSON;\r",
"try { \r",
" responseJSON = JSON.parse(responseBody); \r",
" tests[\"response body has key delay\"] = 'delay' in responseJSON;\r",
"}\r",
"catch (e) { }\r",
"tests[\"response code is 200\"] = responseCode.code === 200;"
],
"_lastExecutionId": "101fa4e8-845a-4ed4-9634-8017a52d87f3"
}
}
]
}
]
},
"environment": {
"id": "9b59b591-e37d-470b-8dcd-ef91d8a3181d",
"values": []
},
"globals": {
"id": "5a06b677-0e9a-448a-a3fe-0772e50b47f2",
"values": []
},
"run": {
"stats": {
"iterations": {
"total": 1,
"pending": 0,
"failed": 0
},
"items": {
"total": 1,
"pending": 0,
"failed": 0
},
"scripts": {
"total": 1,
"pending": 0,
"failed": 0
},
"prerequests": {
"total": 1,
"pending": 0,
"failed": 0
},
"requests": {
"total": 1,
"pending": 0,
"failed": 0
},
"tests": {
"total": 1,
"pending": 0,
"failed": 0
},
"assertions": {
"total": 2,
"pending": 0,
"failed": 0
},
"testScripts": {
"total": 1,
"pending": 0,
"failed": 0
},
"prerequestScripts": {
"total": 0,
"pending": 0,
"failed": 0
}
},
"timings": {
"responseAverage": 3733,
"started": 1504180961407,
"completed": 1504180965257
},
"executions": [
{
"cursor": {
"position": 0,
"iteration": 0,
"length": 1,
"cycles": 1,
"empty": false,
"eof": false,
"bof": true,
"cr": false,
"ref": "4c046f8a-ca94-4450-9300-d49046aa3753",
"_httpId": "2f6cf48e-baf0-4bcd-9a45-096cdb105356"
},
"item": {
"id": "2cf3e4a4-eb9e-4622-bade-d0536161c97d",
"name": "Delay",
"request": {
"url": "https://postman-echo.com/delay/3",
"method": "GET",
"body": {
"mode": "raw",
"raw": ""
},
"description": {
"content": "",
"type": "text/plain"
}
},
"response": [],
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var responseJSON;\r",
"try { \r",
" responseJSON = JSON.parse(responseBody); \r",
" tests[\"response body has key delay\"] = 'delay' in responseJSON;\r",
"}\r",
"catch (e) { }\r",
"tests[\"response code is 200\"] = responseCode.code === 200;"
],
"_lastExecutionId": "101fa4e8-845a-4ed4-9634-8017a52d87f3"
}
}
]
},
"request": {
"url": "https://postman-echo.com/delay/3",
"method": "GET",
"header": [
{
"key": "User-Agent",
"value": "PostmanRuntime/6.2.6"
},
{
"key": "Accept",
"value": "*/*"
},
{
"key": "Host",
"value": "postman-echo.com"
},
{
"key": "accept-encoding",
"value": "gzip, deflate"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"description": {
"content": "",
"type": "text/plain"
}
},
"response": {
"id": "3b5bd4c9-4bd9-4374-95fe-1143ba13dcef",
"status": "OK",
"code": 200,
"header": [
{
"key": "Access-Control-Allow-Credentials",
"value": ""
},
{
"key": "Access-Control-Allow-Headers",
"value": ""
},
{
"key": "Access-Control-Allow-Methods",
"value": ""
},
{
"key": "Access-Control-Allow-Origin",
"value": ""
},
{
"key": "Access-Control-Expose-Headers",
"value": ""
},
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"key": "Date",
"value": "Thu, 31 Aug 2017 12:02:47 GMT"
},
{
"key": "ETag",
"value": "W/\"d-t/L/D5c0SDl+MoXtKdSVOg\""
},
{
"key": "Server",
"value": "nginx/1.10.2"
},
{
"key": "set-cookie",
"value": "sails.sid=s%3AroEN1Y-PMzgC4yUizOhg6EMG9OdEnTYi.mDCzLRsWfYNZDGYgHv0ID4q1cc%2BnzGDOf8n4FgOVTcE; Path=/; HttpOnly"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Length",
"value": "13"
},
{
"key": "Connection",
"value": "keep-alive"
}
],
"stream": {
"type": "Buffer",
"data": [
123,
34,
100,
101,
108,
97,
121,
34,
58,
34,
51,
34,
125
]
},
"cookie": [],
"responseTime": 3733,
"responseSize": 13
},
"id": "2cf3e4a4-eb9e-4622-bade-d0536161c97d",
"assertions": [
{
"assertion": "response body has key delay"
},
{
"assertion": "response code is 200"
}
]
}
],
"transfers": {
"responseTotal": 13
},
"failures": [],
"error": null
}
}
以下是同一集合的示例测试运行导出。你可以看到它有不同的结构:
{
"id": "cd3ae37c-6e84-438e-a488-04ce9287e10d",
"name": "Echo",
"allTests": [],
"timestamp": "2017-09-01T05:56:02.663Z",
"collection_id": "ef224090-5564-258f-6ca5-68bd578a6c8d",
"folder_id": 0,
"target_type": "collection",
"environment_id": "no-environment",
"data": [],
"delay": 0,
"count": 1,
"collection": {
"id": "ef224090-5564-258f-6ca5-68bd578a6c8d",
"name": "Echo",
"description": "",
"order": [
"092eef70-fd70-e83e-5aa5-7ad466335c32"
],
"folders": [],
"folders_order": [],
"timestamp": 1504180718307,
"synced": false,
"remote_id": 0,
"owner": 0,
"sharedWithTeam": false,
"subscribed": false,
"remoteLink": "",
"remoteLinkUpdatedAt": null,
"public": false,
"createdAt": 1504180718307,
"updatedAt": 1504180739783,
"write": true,
"published": false,
"favorite": false,
"permissions": {},
"syncedPermissions": {}
},
"folder": null,
"environment": null,
"globals": [],
"results": [
{
"name": "Delay",
"id": "092eef70-fd70-e83e-5aa5-7ad466335c32",
"url": "https://postman-echo.com/delay/3",
"totalTime": 0,
"responseCode": {
"code": 200,
"name": "OK",
"detail": {
"name": "OK",
"detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action."
}
},
"tests": {
"response body has key delay": true,
"response code is 200": true
},
"testPassFailCounts": {
"response body has key delay": {
"pass": 1,
"fail": 0
},
"response code is 200": {
"pass": 1,
"fail": 0
}
},
"times": [
"4339"
],
"allTests": [
{
"response body has key delay": true,
"response code is 200": true
}
],
"time": "4339",
"totalRequestTime": "4339",
"iterationResults": {}
}
],
"totalPass": 2,
"totalFail": 0,
"totalTime": 4339,
"lifecycle": "done",
"requests": [
{
"name": "Delay",
"id": "092eef70-fd70-e83e-5aa5-7ad466335c32",
"url": "https://postman-echo.com/delay/3",
"time": "2017-09-01T05:56:02.663Z",
"responseCode": {
"code": 200,
"name": "OK",
"detail": {
"name": "OK",
"detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action."
}
},
"testPassFailCounts": {
"response body has key delay": {
"pass": 1,
"fail": 0
},
"response code is 200": {
"pass": 1,
"fail": 0
}
}
}
],
"synced": false
}
我正在使用Postman 5.2.0和Newman 3.8.1(每个Windows的最新版本)。也许这些版本不兼容?我应该使用不同的版本吗?