0
0
PostmanHow-ToBeginner ยท 4 min read

How to Run Postman Collection with Data File for Automated Testing

To run a Postman collection with a data file, open the Postman Runner, select your collection, and upload a CSV or JSON data file. Postman will iterate over each row or object in the file, running the collection with that data automatically.
๐Ÿ“

Syntax

In Postman, running a collection with a data file involves these steps:

  • Open Postman Runner: Click the Runner button in Postman.
  • Select Collection: Choose the collection you want to run.
  • Upload Data File: Add a CSV or JSON file containing test data.
  • Configure Iterations: Postman runs one iteration per data row or object.
  • Start Run: Click Start Run to execute tests with each data set.
postman
No code needed; this is a UI-driven process in Postman.
๐Ÿ’ป

Example

This example shows how to run a collection with a CSV data file containing user credentials.

Data file users.csv content:

username,password
user1,pass1
user2,pass2
user3,pass3

In your request, use variables like {{username}} and {{password}} to access data from each row.

When you run the collection with this CSV file, Postman will run the requests three times, each time replacing variables with the respective row's data.

csv
username,password
user1,pass1
user2,pass2
user3,pass3
Output
Test run executes 3 iterations, each with different username and password values from the CSV file.
โš ๏ธ

Common Pitfalls

  • Wrong file format: Using a file that is not CSV or JSON will cause errors.
  • Variable mismatch: Variables in requests must exactly match the column names or JSON keys in the data file.
  • Empty rows or objects: These can cause unexpected test failures or skipped iterations.
  • Not using Runner: Trying to run data-driven tests without Postman Runner will not work.
http
Wrong way:

// Using variable {{user}} but CSV column is 'username'
GET https://api.example.com/login?user={{user}}&pass={{password}}

Right way:

// Use variable names matching CSV columns
GET https://api.example.com/login?username={{username}}&pass={{password}}
๐Ÿ“Š

Quick Reference

StepDescription
Open Postman RunnerClick the Runner button in Postman UI
Select CollectionChoose the collection to run
Upload Data FileAdd CSV or JSON file with test data
Check Variable NamesEnsure request variables match data file keys
Start RunClick Start Run to execute iterations
โœ…

Key Takeaways

Use Postman Runner to run collections with CSV or JSON data files for multiple test iterations.
Ensure variable names in requests exactly match the data file columns or keys.
Only CSV and JSON formats are supported for data files in Postman Runner.
Each row or object in the data file triggers one iteration of the collection run.
Avoid empty rows or mismatched variables to prevent test failures.