6. Automated Collection Runner

Manually clicking "Send" for dozens of requests is time-consuming. When you want to run your entire testing suite—such as checking that signup, login, profile editing, and deletion work perfectly in sequence—you use the **Postman Collection Runner**.

What is the Collection Runner?

The Collection Runner allows you to execute all requests within a collection or folder in a specific sequential order. It runs each request, executes its associated pre-request scripts, hits the server, executes the assertions in the Tests tab, and prints a comprehensive consolidated report showing Passes and Failures.

Data-Driven Testing (CSV/JSON)

Often, you want to run the same request multiple times with different sets of inputs (e.g., testing that your register API successfully registers 50 different users with distinct emails, or blocks weak passwords). You can feed these values into the Collection Runner using a **data file** (CSV or JSON).

Step 1: Create a Data Sheet (CSV)

Create a standard CSV file where the column headers match the Postman variable placeholders:

username,password,expectedStatus
user_alpha,Pass123!,201
user_beta,weak,400
user_gamma,Pass456!,201

Step 2: Reference in Requests

In your Request Body (JSON), use double curly braces to fetch values dynamically from the spreadsheet:

{
  "username": "{{username}}",
  "password": "{{password}}"
}

In the Tests tab, check the status code against the spreadsheet's expected values using pm.iterationData:

pm.test("Verify status code against test data", function () {
    let expected = pm.iterationData.get("expectedStatus");
    pm.response.to.have.status(Number(expected));
});

Step 3: Launch in Runner

  1. Select your collection and click the **Run** button (or click three dots next to the collection name and select **Run Collection**).
  2. In the configuration sidebar, select the **Functional** tab.
  3. Click **Select File** under the Data section and upload your CSV or JSON file.
  4. Postman will automatically detect the number of **Iterations** (rows of data, e.g. 3 runs).
  5. Click the orange **Run [Collection Name]** button.
  6. Observe the runner board cycling through iterations automatically and generating a detailed pass/fail dashboard!

Controlling Request Flow Dynamically

By default, Postman executes requests in the linear order they appear in the collection. However, you can override this order programmatically inside the Tests tab using the pm.execution.setNextRequest() workflow control function:

// Skip to a specific request by its exact saved name
if (pm.response.code === 400) {
    pm.execution.setNextRequest("Error Handling Request");
} else {
    pm.execution.setNextRequest("Normal Profile Page");
}

// To stop the runner execution immediately, pass null
// pm.execution.setNextRequest(null);
Execution Warning: If you use setNextRequest(), make sure you don't create an infinite loop! If request A sets next request to B, and B sets next request to A, the collection runner will cycle endlessly until it crashes the application or depletes memory.