Data Driven Testing using a csv file for automation

I am new to Postman and trying to determine if this tool can support our API automation testing requirements.

Today we are creating spreadsheets to determine each test scenario and the desired outcome. Then each test case is created in Postman, which is very time consuming and error prone. Then the call is made and the response is manually check to see if the test pass or not. Then someone goes back into Postman then creates automation. I know there is a better way to handle this in Postman.

I checked out this -

Appears I can use a csv file that is comma delimited, where the 1st row represents the variable and the data set is listed below for each API call. I can then assign a variable, in this case to each variable in the json body that I want changed for each API call.

I wasn’t able to find a ton of information, so thought I would ask my specific question here. I did see that Postman was able to validate each response to determine if the test passed or not. Can someone point me to some documentation on how I can setup Postman to determine if each data set passed or failed? I believe I read that I can include in the csv file my pass/fail criteria was in each response and I had to add some code?

I then want to automate the call, so it continues to use the same call and data set for regression testing.

Hello dbaker,

After reading this it appears that you want to use a data file (CSV, JSON is also supported) and pass in a variables for testing an API. One of the values in the CSV would be as input to the request, the the other value would be used in testing the response. For my code sample I am going to use the Postman echo API which just returns all the parameters you send to it. You can read more about it here:

I am going to using the following simple request and pass in my CSV file in the collection runner:{{var}}

The simple CSV file that looks like this:

var, test
1, 1
2, 2
3, 3
john, xxx

and is used as input for the collection runner.

I added following in the Test tab:

const test = pm.variables.replaceIn(’{{test}}’)

pm.test(“Body matches string”, function () {

Basically I am setting a js var “test” to what is getting passed in from the CSV. And then I am testing that my body contains that value. All of the tests pass with the exception of the last entry where I pass in “john” and test for “xxx”.

So that is how is my simple example of creating a data driven using Postman. Let me know if that helps.


Thank I’ll try this out and reply here.

Thanks for the help. I was successfully able to create several automation tests using the csv file for data input and asserts.