【问题标题】:How to terminate collection Iterations in postman if test fails如果测试失败,如何在邮递员中终止收集迭代
【发布时间】:2021-01-14 22:20:37
【问题描述】:

我正在使用邮递员来实现 API 的自动化。创建了集合运行器,在执行时,我将 Iterations 提供为 5。如果任何场景失败,我会尝试停止整个测试。

我尝试了以下选项。但是当前的测试失败了,但它会进入下一次迭代。如何停止整个迭代?

  • postman.setNextRequest(null);
  • 抛出新错误('halt')

【问题讨论】:

    标签: postman postman-collection-runner


    【解决方案1】:

    正如你提到的,你可以使用postman.setNextRequest(null) 并在你的测试中做这样的事情:

    // I used 500 status code for stopping condition
    if(pm.response.code === 500) {
        postman.setNextRequest(null)
    }
    

    【讨论】:

      猜你喜欢
      • 2021-09-04
      • 2020-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-07
      • 2018-07-29
      • 1970-01-01
      • 2022-11-27
      相关资源
      最近更新 更多