Hello Folks,

We have already seen How to read data from a csv file in Postman.

I have not discussed a major purpose of usage of data files in Postman yet. We are going to learn about that in this post.

The major usage of reading data from files such as JSON and CSV in Postman is to achieve Data Driven Testing. Did not understand the term Data Driven Testing? Let me explain.

Suppose we have an API to login to application and gives valid token only on successful credentials and meaningful error messages on wrong credentials. You need to test below scenarios for above API:-

  1. Both username and password are correct.
  2. Both username and password are incorrect
  3. Only username is incorrect
  4. Only password is incorrect
  5. Username is missing
  6. Password is missing

To test all above scenarios for API, you have two options:-

  1. Create as many requests as scenarios i.e. six different requests for different request body
  2. Use Data driven testing i.e run single request with different set of data.

API will behave based on data you are passing. You just need to pass different set of data to same API. This we can achieve easily using data files feature in Postman.

Let’s understand this with example:-

In How to read data from a csv file in Postman ,I purposefully created just single row of data. In fact, each row is a set of input data to API. If your data file consists of five rows, API will run five times considering each row as new set of data.

I will consider the same API used in How to read data from a csv file in Postman . Now I want to do multiple booking with different data. Let’s create a sample CSV first. Each new set of data should be a row in csv.

So my csv file will look like as below:-

So the booking API will run thrice. First data row (2) will be used for first run, second data row will be used for second run and so on.

You do not need any extra setup to run. You just need to run API using collection runner and select the csv file in Data section.

Run the collection, you will see three iteration have run with different data.

Data for iteration 1:-

Data for iteration 2:-

Data for iteration 3:-

#ThanksFoReading

You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply