Using setNextRequest in test script with folders

I have a collection in Postman with folders that are structured like this:

Team Collection
Season1 (folder)
Stats (folder)
Player1 Tests (folder) - contains a pre-request and a test script. If the request name is “R2”–> It calls setNextRequest(“Player3 Tests”)
Player2 Tests (folder)
Player3 Tests (folder) - contains pre and post request tests.

I’m hoping to get the Player3 Tests folder’s tests to execute, but it’s not working as it stands with setNextRequest(“Player3 Tests”).
I’ve selected Player1 Tests, Player2 Tests, and Player3 Tests from the collection runner before executing the run. Is there something I might be missing to make this work in the collection runner? Or does the folder level execution only work from Newman and not the collection runner in the Desktop app

setNextRequest just sets the next request that will run after the current request and all of the code in any pre-request script and tests tab has completed.

The key element here is request.

You can’t run a folder, so you will have to tell it to run the first request within that folder. In this case it would be R4.

Not sure if your logic for this is correct. The Collection runner runs requests run by folder then request order.

If you have a pre-request script for the Player1 folder looking for R2 (which will always be true). Then it will always skip the Player2 folder and miss R3 as far as I can tell from the logic you provided.

1 Like

Thanks for your help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.