【问题标题】:How can I print the assertion with a value even if it get passed in Postman Api Testing即使它在 Postman Api 测试中通过,我如何打印带有值的断言
【发布时间】:2022-01-22 18:40:39
【问题描述】:

作为用户,在执行为 API 请求创建的测试用例时,我希望即使测试用例通过,它也必须显示断言的值。

例如:

pm.test("User ID Should Exist", ()=>{

    value = bodyData.data.currentUser.id

    pm.expect(value).to.exist

    pm.environment.set("userID", value) 
})

当我运行它时,它会显示:

PASS - 用户 ID 应该存在

即使案例在测试结果部分/选项卡上通过,我如何打印用户 ID 的值?

【问题讨论】:

    标签: postman postman-collection-runner postman-testcase postman-native-app postman-mocks


    【解决方案1】:

    您可以执行以下操作:

    value = bodyData.data.currentUser.id
    
    pm.test("User ID '" + value + "' should Exist", ()=>{
    
        pm.expect(value).to.exist
    
        pm.environment.set("userID", value) 
    }) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-27
      • 1970-01-01
      • 2020-12-31
      • 2021-09-10
      • 1970-01-01
      • 2019-04-11
      • 2019-04-01
      • 1970-01-01
      相关资源
      最近更新 更多