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
Runnerbutton in Postman. - Select Collection: Choose the collection you want to run.
- Upload Data File: Add a
CSVorJSONfile containing test data. - Configure Iterations: Postman runs one iteration per data row or object.
- Start Run: Click
Start Runto 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
| Step | Description |
|---|---|
| Open Postman Runner | Click the Runner button in Postman UI |
| Select Collection | Choose the collection to run |
| Upload Data File | Add CSV or JSON file with test data |
| Check Variable Names | Ensure request variables match data file keys |
| Start Run | Click 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.