How to import Newman test results into Postman

1.4k views Asked by At

In the documentation for command line integration with Newman it says:

The results of all tests and requests can be exported into a file and later imported into Postman for further analysis. Use the JSON reporter and a file name to save the runner output into a file.

I have tried exactly that:

newman run "Echo.postman_collection.json" --reporters cli,json --reporter-json-export outputfile.json

But I did not manage to import the outputfile.json into the Postman Collection Runner. I am always getting the following error message:

runner.js:81831 Uncaught DataError: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value.

What am I doing wrong?

Here is the outputfile.json created by Newman. It actually has a different structure than a test run exported in the 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
  }
}

And here is a sample test run export for the same collection. You can see that it has a different structure:

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

I am using Postman 5.2.0 and Newman 3.8.1 (latest release for Windows each). Maybe these versions are not compatible? Shall I use different versions?

0

There are 0 answers