【问题标题】:How to set failed in POSTMAN Collection runner via script如何通过脚本在 POSTMAN Collection runner 中设置失败
【发布时间】:2018-08-09 17:50:37
【问题描述】:

如何通过脚本设置“失败”?我有一个 IF,如果我想检查 X 是否与 Y 比较,我想在这个中获得一个“FAILED”。现在我在控制台中得到一个“失败”,但测试是“通过”。我已经搜索了其他网站,但没有发现任何相关信息。希望你现在是我的意思。

   if(pm.iterationData.get("ProfileSeries") == response.ProfileSeries){
    console.log("expProfileSeries " + pm.iterationData.get("ProfileSeries") + " = "+ response.ProfileSeries);
    }
    else{
         console.log("FAILED");
}

【问题讨论】:

  • 什么是response.ProfileSeries?您能否提供一个响应正文的示例。

标签: if-statement console postman postman-collection-runner


【解决方案1】:

添加pm.test 和相关的pm.expect

pm.test('ProfileSeries should be equal', function () {

pm.expect(pm.iterationData.get("ProfileSeries")).to.equal(response.ProfileSeries);

});

【讨论】:

    猜你喜欢
    • 2018-11-23
    • 2017-01-15
    • 2020-07-08
    • 2021-08-27
    • 1970-01-01
    • 2019-03-13
    • 2018-11-15
    • 2017-02-12
    • 2020-01-06
    相关资源
    最近更新 更多