Data-driven testing in Postman allows you to run the same API request multiple times using different sets of input data. This is commonly achieved using external data files such as CSV and JSON, making your API tests scalable, reusable, and efficient.
Postman replaces variables like {{variableName}} with values from each row (CSV) or object (JSON) during execution.
// Access CSV or JSON data variable in Postman
let username = pm.iterationData.get("username");
let password = pm.iterationData.get("password");
pm.environment.set("user", username);
pm.environment.set("pass", password);
For each iteration, Postman injects a new username and password into the request. The same API endpoint is tested repeatedly with different data sets.
// Example CSV file structure
username,password
admin,admin123
user1,pass123
user2,pass456
// Example JSON data for Postman Runner
[
{
"username": "admin",
"password": "admin123"
},
{
"username": "user1",
"password": "pass123"
}
]
Edit the data below and click "Run Runner" to see how Postman replaces variables.