Test Overview
This test checks that the Postman collection runs the expected number of iterations. It verifies the iteration count matches the configured value.
Jump into concepts and practice - no test required
This test checks that the Postman collection runs the expected number of iterations. It verifies the iteration count matches the configured value.
pm.test('Iteration count is correct', function () { const expectedIterations = 3; const actualIterations = pm.info.iteration; pm.expect(actualIterations).to.be.below(expectedIterations); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts in Postman runner | Postman collection runner is open with iteration count set to 3 | — | PASS |
| 2 | Postman runs first iteration (iteration index 0) | Request sent, response received | Check pm.info.iteration is 0 and less than 3 | PASS |
| 3 | Postman runs second iteration (iteration index 1) | Request sent, response received | Check pm.info.iteration is 1 and less than 3 | PASS |
| 4 | Postman runs third iteration (iteration index 2) | Request sent, response received | Check pm.info.iteration is 2 and less than 3 | PASS |
| 5 | Postman stops running after 3 iterations | Collection run complete | Total iterations run equals configured iteration count 3 | PASS |
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);
}