Best way to skip a folder/collection from running

Hi Team,

Would like some suggestion on a problem that I have
We currently have postman tests running in our CI/CD pipeline across different environments, with a folder structure as such

Feature

  • Collection 1
    • Request 1
    • Request 2
    • Request 3
  • Collection 2
    • Request 1
    • Request 2
  • Collection 3
    • Request 1
    • Request 2
      And so on

Of course during development we will run into issues where, there are bugs in a particular environment, and hence a particular collection will fail, and hence the pipeline will show that a test fails. Which is great! And not great at the same time, because I don’t want it to keep running the failed tests, I want to exclude these tests so that we don’t waste time/resources to run these tests until I know that a fix has been made.

So I have several questions regarding this:

  • How would I go about skipping a whole collection? For example, I only want to run Collection 1 and Collection 3 only. At the moment I am skipping a whole feature, but if only 1 collection is failing, I want to be able to run the other ones. I have tried doing postman.setNextRequest({{folderName/folderId}}), at the folder/collection level, but it would just run Collection.Request1 and stop there, instead of running the whole collection. Is there a way to skip only a particular collection?

  • If not, am I structuring my tests wrong perhaps? What would be the suggestion to deal with an issue such as this? I’m sure this is a fairly common scenario, would love to hear how other people structure/deal with this!

Thank you

This is a really great question!

Since requests should be executed sequentially from top to bottom, you could put that setNextRequest call right before where you’d want to skip and use the ID of the first request in the collection that you wish to resume from.

For example:
Collection 1, Request 3: postman.setNextRequest(ID_OF_C3R1) //Skip Collection 2
Collection 3, Request 5: postman.setNextRequest(ID_OF_C6R3) //Skip Collection 4 & 5 as well as 6’s first 2 requests

Hope this helps! :smile:

2 Likes

This works like a charm, Hadn’t thought of this before, thank you very much for your help!

Unfortunately, for postman, it’s better to use the name of the request you want to jump to if you plan to use their Forks integration. String comparing is rarely a good suggestion unless there’s no other way, but I learned the hard way that Postman has zero workarounds for skips to work in Forks, where the GUID changes (since a Fork is just a copy).