首页 > 解决方案 > Newman - 获得与手动 Postman 导出相同的测试运行结果 json

问题描述

当我在 Postman 中完成手动收集时,我会得到以下格式的测试运行结果:

{
    "id": "f1280278-4ec5-44d9-97b3-77d20e74b730",
    "name": "Things Newman",
    "timestamp": "2021-05-30T13:04:28.772Z",
    "collection_id": "01f79316-8ddc-4d06-a8d4-5a9a315a67ee",
    "folder_id": 0,
    "environment_id": "ab5c0adb-d80c-482f-a21a-8c5078696aae",
    "totalPass": 58,
    "totalFail": 18,
    "results": [
        {
            "id": "2d403678-d0d6-4295-8cb2-a189bc0d6a5f",
            "name": "utility_get_access_token",
            "url": "https://blablabla/token",
            "time": 293,
            "responseCode": {
                "code": 200,
                "name": "OK"
            }, ...

我没有得到与纽曼相同的结果:

newman run collections/things.postman_collection.json --environment environments/things_DEV.postman_environment.json -r json,html --reporter-json-export output.json –-reporter-html-export Reports.html --disable-unicode --color off

我以不同的格式得到它:

{
  "collection": {
    "_": {
      "postman_id": "01f79316-8ddc-4d06-a8d4-5a9a315a67ee"
    },
    "item": [
      {
        "id": "1b6d3a2b-013c-4fae-8b65-fbe21606d141",
        "name": "api/v1/retail-lending",
        "item": [
          {
            "id": "a40a69a4-a12d-496a-b254-ea9dd2fa95d1",
            "name": "utility_get_access_token",
            "request": {
              "url": {
                "path": [
                  "auth",
                  "realms",
                  "internal",
                  "protocol",
                  "openid-connect",
                  "token"
                ],

显然没有显示测试是否轻松通过或失败,这使我的生活变得更加难以解析它。

如何以编程方式使用 newman 获得与从 Postman 手动导出收集测试结果相同的结果?

标签: jsonautomated-testspostmanpostman-collection-runner

解决方案


推荐阅读