0
0
Postmantesting~10 mins

Run order and flow control in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test demonstrates the default sequential order in which Postman requests run within a collection and shows that simply setting environment variables does not automatically manage flow control or conditional execution.

Test Code - Postman
Postman
pm.test("First request runs", function () {
    pm.expect(true).to.be.true;
});

// Set a variable to control flow
pm.environment.set("runNext", "second");

// Second request test script:
pm.test("Second request runs only if runNext is 'second'", function () {
    pm.expect(pm.environment.get("runNext")).to.eql("second");
});

// Change variable to stop further requests
pm.environment.set("runNext", "stop");

// Third request test script:
pm.test("Third request should not run if runNext is 'stop'", function () {
    pm.expect(pm.environment.get("runNext")).to.not.eql("stop");
});
Execution Trace - 6 Steps
StepActionSystem StateAssertionResult
1Start collection run in PostmanPostman collection runner opens with three requests queued-PASS
2Run first request and execute its test scriptFirst request response receivedCheck that the test 'First request runs' passesPASS
3Set environment variable 'runNext' to 'second'Environment variable 'runNext' is set to 'second'-PASS
4Run second request and execute its test scriptSecond request response receivedVerify 'runNext' equals 'second' in test scriptPASS
5Set environment variable 'runNext' to 'stop'Environment variable 'runNext' is set to 'stop'-PASS
6Attempt to run third request and execute its test scriptThird request response receivedCheck that 'runNext' is not 'stop' (expected to fail)FAIL
Failure Scenario
Failing Condition: Third request runs even though 'runNext' is set to 'stop', causing assertion failure
Execution Trace Quiz - 3 Questions
Test your understanding
What controls the order of requests in this Postman test?
AEnvironment variable 'runNext' set in test scripts
BThe order requests are listed in the collection only
CRandom selection by Postman
DManual user clicks during run
Key Result
Postman runs collection requests sequentially by default. Control run order and skip conditionally using postman.setNextRequest(name or null) in test/pre-request scripts or pm.execution.skip() in pre-request scripts, driven by environment variables if needed.