Search code examples
javascripttestingpostmanpostman-collection-runner

Postman: How to iterate my JSON file in test?


I have a JSON file, it's an array of 6 objects.

I want to run the test 3 times per object.

When I set the Iterations option to 3 on the Collection Runner page, it runs my test one time per first three objects, when I want it to loop through the whole array 3 times.

My data:

[{"id": "101"},{"id": "102"},{"id": "103"},{"id": "104"},{"id": "105" },{"id":"106"}]

My test: enter image description here


Solution

  • I don't think that you can make it do what you want it to do in the collection runner - It could be done in a Newman script but not through the UI...I may be wrong. The Iterations number in the UI relates to the data set in the JSON (as seen in the preview below) rather than the number of times it loops through that data. So if you add 3 it’s only going to make three requests using the 101, 102 and 103 values.

    Iterations

    In order to get what you want you would probably need to replicate the 101 > 106 values three times in the JSON file and set the iterations value to 18

    Postman Runner