Data Driven Testing with Postman using CSV and JSON files

We can use CSV and JSON files to get data for our Postman test scripts. This is extremely useful when we need to execute a test with multiple set of Data. Also, modifying or adding any data fields will just need updating the data files which is easier than going to test script and updating test data. So, in this post we will see can we achieve this.

For testing purpose we will use a sample online REST API from, https://reqres.in/ without the need of creating any new api.

Steps to do this

  1. Create a new request in Postman, with Request API- https://reqres.in/api/register . Header & Body as given below:
{
“email”: “eve.holt@reqres.in”,
“password”: “pistol”
}
Image for post
Image for post
Image for post
Image for post

Save the POST request.

2. Now, let us consider that we want to refer EMail ID, Password and Endpoint from the CSV File. So, click on … (3 Dots) in the Collection, Edit, and then Variables.

Image for post
Image for post

3. Add all the variables with their Initial Value(Can be anything).

4. Update the Post request. Parameterize this, so that going ahead values will be read from variables.

Image for post
Image for post

5. Create a CSV file having these 3 variables and values.

Image for post
Image for post

6. Goto Collection Runner, and import this data file. and finally click on Run button.

Image for post
Image for post
Image for post
Image for post

7. Now, let us do the same thing with JSON file. Create a new JSON file, and in Collection Runner use this JSON file.

Image for post
Image for post
Image for post
Image for post

I’ve added the Collection JSON and sample CSV to my github repo — please feel free to download and use.

Let me know if this was helpful. If you ever need my help, you can write in comments sections. Also, you can contact me through my LinkedIn Profile.

Written by

Software Automation Testing expert with 9 years of work experience in diverse tools and technologies.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store