簡體   English   中英

在 postman 中,我如何根據另一個測試是通過還是失敗來運行新測試?

[英]In postman, how can i run a new test based on whether another test has passed or failed?

我有兩個測試測試 A 和測試 B。我希望 B 只有在 A 通過時才運行。 我怎樣才能在 postman 中做到這一點?

pm.test("Status code is 200", function() {
    pm.response.to.have.status(200);
});
pm.test("Check if fruits found with this search criteria", function() {
    pm.expect(responseData.Message).to.not.eql("No fruits found with this search criteria");
});

僅當這兩個測試用例通過時,我才想運行第三個測試。 我怎樣才能做到這一點? 提前致謝。

您可以簡單地嵌套測試:

pm.test("Status code is 200", function() {
    pm.response.to.have.status(200);

    pm.test("Check if fruits found with this search criteria", function() {
        pm.expect(responseData.Message).to.not.eql("No fruits found with this search criteria");

        pm.test("Third test", function() {
            //pm.expect()...
        });
    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM