If the data is not used, skip the test case

Hello team,

Some background is I currently have a csv file as a data injection point so in the pre-request script I have parameter as

{
currency: data.currency
}

and data.currency is in the csv file, which works fine.

But in my collection there could be some requests which don’t even use data.currency in their requests and if in this condition, I just want to skip the tests and move forward. Is there any way to achieve this? Thanks!

Hi @max.shin Welcome to the community :slight_smile:

You can try the below options based on the condition you want:-

  1. You can skip certain test within collection by directly using the postman.setNextRequest(‘Request Name’); function as per your need in Tests.

Or

  1. You can use pm.test.skip to skip a test

const shouldSkipped = true; //condition to be set true if the test has to be skipped, and false otherwise.

(shouldBeSkipped ? pm.test.skip : pm.test)(“Status code is 200”, () => {

pm.response.to.have.status(200);

});

In our community we would already have existing posts which can help you solve your queries, so just make sure to search your issue once in the community. To better understand on how to search your issue check this

2 Likes