【问题标题】:How to add Postman test asset error or success message如何添加 Postman 测试资产错误或成功消息
【发布时间】:2023-01-12 10:36:44
【问题描述】:

在邮递员中我有以下测试。如何给出断言成功或错误信息。我不想将消息作为 console.log("my msg")。 Coz 控制台消息转到控制台。我想在邮递员显示通过或失败的图片中显示消息。

pm.test("Full version number present in response headers optional", () => {
let apiVersion = pm.response.headers.get("API-Version")
pm.expect(apiVersion).match(/[-.0-9]+/)
})

【问题讨论】:

    标签: testing postman-testcase postman-newman


    【解决方案1】:

    here 中的官方文档。

    演示示例

    var jsonData = JSON.parse(responseBody);
    const apiVersion = undefined
    pm.test('Full version number present in response', function () {
        pm.expect(apiVersion).match(/[-.0-9]+/)
    });
    
    const apiVersion1 = '1.2.3'
    pm.test('Full version number present in response', function () {
        pm.expect(apiVersion1).match(/[-.0-9]+/)
    });
    
    pm.test('Full version number present in response', function () {
         pm.expect(null,"extrame message").match(/[-.0-9]+/)
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-11
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多