How to skip an iteration in a collection

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Here’s an outline with best practices for making your inquiry.

My question: I want to skip an iteration based on a global variable. SO i have wrapped that around an If/Else block and the else part will skip the test. So the result is the tests are being skipped but I have 2 problems seeing them on the html extra report:

  1. The skipped iterations are not coming under “Total Skipped Tests” of the report.
  2. Even if the iteration is skipped, I see the iteration# mentioned in the report with a description that there are no tests to execute in this iteration. I just want to check whether is it possible to not even report that iteration.

Details (like screenshots):

How I found the problem:

I’ve already tried: I have already tried postman.setNextRequest(null) but as per the documentation this will be called towards the end and will mark an iteration in my report. Please suggest.

Hi there @mkdeloitte - have you tried pm.test.skip - see example.

Yes I tried that but that is going to skip the test but not the iteration. I want to skip the iteration.

If your goal is to skip the request entirely, can you put your if/else logic in the Test script of the preceding request?

hi Joyce,
I did that. The if part contains the tests to be executed and the else part has “postman.setNextReqeust(null)” . So what this does is it will perform the iteration but will skip the tests. And in the report we will see the iteration execution will be available with “No Test To Run” details under it…My requirement is not to let that iteration itself visible in the report.

@dennysutanto can you please help

@joyce so if u see above…I just want the execution for Iteration 1 and 2 but not the other 13…but then also it appears in my report. Is there a way I can skip these iterations

I wonder if someone else has a workaround.

If not, htmlextra is an open-source project that is not managed by the Postman team. You might consider submitting a feature request or even contributing back to the project with a pull request (after verifying this is a welcome change).