0

此循环中的问题//测试以检查 W2B001 也从 API 接收到//测试响应是 Int 或日期

我有一个这样的数组

"dates": [{
      "id": 1,
      "date": "2019-06-30T00:00:00"
    },
    {
      "id": 2,
      "date": "2019-04-30T00:00:00"
    },
    {
      "id": 3,
      "date": "2019-08-31T00:00:00"
    },
    {
      "id": 4,
      "date": "2019-10-31T00:00:00"
    },
    {
      "id": 5,
      "date": "2019-02-28T00:00:00"
    },
    {
      "id": 6,
      "date": "2018-12-31T00:00:00"
    }
  ]
};


pm.test("Verify that the Address Type and Datatype are matching the Soap UI response ", function () {
    for (var i = 0; i < jsonData.dates.length; i++)
        {
            var datedata = jsonData.dates[i].date;
            if (datedata === "2019-06-30T00:00:00") {
                pm.variables.set("test_status", "passed");
                console.log(datedata);
            }else
            {
                pm.variables.set("test_status", "failed");
            }
    }
    console.log(pm.variables.get("test_status"));
    console.log(datedata);
    console.log(jsonData.creditCommitments.length);
});

我想验证日期是否匹配,但我面临的问题是邮递员收到的数组元素并不总是按排序接收。所以它通过了一次,第二次没有通过。任何想法如何解决它?

4

0 回答 0