Can I stop test collection if one test fails?

So I’m running a collection and sometimes the service is down. Because of this i will get a 404 Error which is fine, but I don’t need to run the entire test collection afterwards since obviously every test will fail.
Is there a way to stop the entire collection from continuing if a specific test fails?

Hey @legendariusx,

Welcome to the community! :star:

If you’re using the runner to run the collection, you could use postman.setNextRequest(null) in an if statement to stop the run from continuing.

Hitting the 404 status code for the request, could be the condition that triggers it?

if(pm.response.code === 404) {
    postman.setNextRequest(null)
}
else {
    // Run the tests...
}

Not the most elegant way of doing it but it might work for you. :smile:

1 Like

Exactly what I was looking for. Thanks a lot!

1 Like