Verify iteration count in Postman collection runner
Preconditions (2)
✅ Expected Result: The request is executed exactly 3 times as per the iteration count set
Jump into concepts and practice - no test required
pm.test('Iteration count is within expected range', function () { pm.expect(pm.info.iteration).to.be.below(3); });
This test script uses pm.info.iteration to get the current iteration number, which starts from 0. The assertion checks that the iteration number is less than 3, meaning the test runs exactly 3 times (0, 1, 2). This confirms the iteration count is respected during the collection run.
Using pm.test defines a test with a clear name, and pm.expect is used for assertion following Postman best practices.
Now add data-driven testing with 3 different data sets and verify iteration count for each
iterationCount setting in Postman control?console.log(pm.info.iteration);
pm.test('Check iteration', () => {
pm.expect(pm.info.iteration).to.be.below(3);
});if (pm.info.iterationCount > 3) {
postman.setNextRequest(null);
}