top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Data Driven Testing in Postman

Data-driven testing means running the same API request multiple times with different sets of input data. Instead of manually changing values each time, we use a dataset  to provide inputs automatically.

 

Why Use Data-Driven Testing?

  • No repetitive work – one test covers multiple scenarios.

  • More coverage – quickly test both positive and negative cases.

  • Saves time – a single request runs with multiple inputs in one go.


Postman provides two ways to pass sets of values to use in a collection run.

1.    CSV File

2.    JSON File

 

By selecting a JSON or CSV data file in the Collection Runner, we can test our requests with multiple different values as part of a single run.

 

Flow of Data Driven Testing:

1. Plan Your Test - Decide which API to test and which inputs will change.

 

2. Prepare Test Data

  • Create a CSV  or JSON  file.

  • Each row/object is a separate test case.


3. Parameterize Requests

  • Replace variable parts of the request (body, URL, headers) with placeholders like {{name}}.


4. Add Assertions

  • Define checks to validate responses automatically, like status codes or returned values.


5. Run Tests

  • Use Postman Collection Runner or Newman.

  • Each row/object runs as a separate iteration automatically.


6. Review Results

  • Check which tests passed or failed.

  • Analyze responses and generate reports if needed.

Data Driven Using CSV File:


1. Create a CSV file with the first row as headers (variable names) and each following row as a separate test case.


ree

Here, Name, Email, Gender, and Status will be used as variables in Postman.

 

2. Use CSV variables in your POST request to https://gorest.co.in/public/v2/users In the body, reference the CSV headers inside double curly braces, 


ree

Postman will replace these placeholders with values from each row when you run the collection with the CSV.

 


Step 3: Validate Results in Scripts

1. Click on post response script and add assertions.

2. We can also save response values for later use.

ree

This allows chaining requests, e.g., GET the user after POST.

 

Step 4: Run Collection with CSV File

1.  Click on “…” next to collection name.   Select on Run option.

2. Click on Select File and Upload your CSV file


ree

3. Click Run.


ree

 

Postman executes one iteration per row. Here as there are 4 set of data so 4 rows will run the request 4 times with their respective values.


Passing Data using Json File:


Step 1: JSON data file must start with an array ([...]), where each object ({...}) represents one test case. This Json file has 3 sets of data this we will pass to POST request


ree

2. Parameterize variables in the POST request body using values from the JSON file (e.g., {{Name}}, {{Email}}) to send requests to https://gorest.co.in/public/v2/users.


ree

 

The {{Name}}, {{Email}}, etc., are like blanks in a form. When Postman runs the test, it fills in each blank with the corresponding value from  JSON file for that test.

Make sure the names match exactly, including capital letters, otherwise Postman won’t recognize them.


Step 3: Validate Results in Scripts tab

Click on post response script and add assertions.



ree

 

 Step 4: Run Collection with Json File

 1.  Click on “…” next to collection name.   Select on Run option.

 2. Click on Select File and Upload your CSV file


ree

 

3. Click Run.


ree

As there are 3 set of data API has run three times. Each time, a different set of data will be picked up.


This way, we can perform data-driven testing, which makes API testing faster and more reliable.

 
 

+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page