In this blog , we will learn how to do Data Driven Testing using CSV file and JSON file by passing 3 sets of data to register 3 user. Then we will generate Newman HTML report and run the Postman Collection in Jenkins .

Postman
Postman is a standalone software testing API (Application Programming Interface) platform to build, test, design, modify, and document APIs. It is a simple Graphic User Interface for sending and viewing HTTP requests and responses.
Why is Postman tool used?
Postman can be used to write functional tests, integration tests, regression tests, and more. Postman's Node. js-based runtime contains support for common patterns and libraries that you can use to build tests quickly.
What is Postman and how it works?
Postman enables you to create and send API requests. Send a request to an endpoint, retrieve data from a data source, or test an API's functionality. You don't need to enter commands in a terminal or write any code. Create a new request and select Send, and the API response appears right inside Postman.
API testing is a type of software testing that analyzes an application program interface (API) to verify that it fulfills its expected functionality, security, performance and reliability. The tests are performed either directly on the API or as part of integration testing.
Postman Collection
Postman Collection is called as suite
Each collection has many Requests
Every Request is called as 1 Test Case
Execute all the Test as one Suite by Test Runner
In this blog we will using the below website to do Data Driven Testing
https://reqres.in/
Post Request
Request Body/Request Payload
Request/api/register
{ "email": "eve.holt@reqres.in", "password": "pistol" }
Response Body
Response200
{ "id": 4, "token": "QpwL5tke4Pnpja7X4" }
Setting global variable endpoint

Endpoint is given in this format {{endpoint}} in URL
Here we pass the request body in Request Body -> JSON format
When we send the request , it gives us the Resposnse Body

Data Driven using json file , Here we have to give set of data in JSON format
reqres.json
[
{
"endpoint":"api/register/reka",
"email":"reka@reqres.in",
"password":"pondy"
},
{
"endpoint":"api/register/raja",
"email":"raja@reqres.in",
"password":"france"
},
{
"endpoint":"api/register/arthi",
"email":"arthi@reqres.in",
"password":"jersey"
}
]
Data Driven using CSV file , Here we have to give set of data in EXCEL format
reqres.csv
endoint | password | |
api/register/reka | reka@reqres.in | plano |
api/register/raja | raja@reqres.in | france |
api/register/arthi | arthi@reqres.in | jersey |
Since we are going to take data from csv file and json file , we have to pass request body as below in json format , where email and password will be taken from externa file
{
"email": "{{email}}",
"password": "{{pasword}}"
}

Here we have to give set of Tests Scripts in Tests for validating the response
Validation Points
Status Code
Header Presence
Header Content Type
Response body has email
Validation Scripts
//checking status code
pm.test("Status code is 201", function () {
pm.response.to.have.status(201);
});
//verify content type header is present or not
pm.test("verify content-Type header present",function(){
pm.response.to .have.header("Content-Type");
})
//verify exact value of content type
pm.test("content-Type value",function(){
pm.expect(pm.response.headers.get("Content-Type")).to.eql("application/json; charset=utf-8")
})
//checking for email
tests["Verify Email"]=responseBody.has("email")

Then to run the Single Request multiple times for multiple users we have to Run Collection

Here we have to run the tests Iterations : 3 times as we have 3 users
Time gap between each request is Delay : 3 ms
We have to specify the type of File we are going to use JSON File
Click preview and check the data
Click Run
If you want to run only one Request

If u want to run multiple request in Single run

Preview of JSON file to be used for running the tests.

After you click run , you can see the test has run 3 times for each user and Validation of Response body is done for each user
You can view the summary and Results
Register success and created for 3 users
Status Code 201
Summary

Results

Register Success for multiple request




You can check in console the Request Body and Response Body for each user

Console Request Body

Console Response Body for Each user



Similarly you can do Data driven using CSV File , Preview the file and Execute the Test


Preview with CSV File

Lets see how to generate Newman report
To Export the postman collection , you can click export


To Share the Report you can click share then click API and copy the Postman API URL


To run the postman collection in command prompt , You can use the path of the Exported Postman Collection or Postman API URL

To Generate Newman HTML Report , run the command in command prompt

Reports will be saved in Newman folder


To Generate Newman HTML Report


Running the Postman collection in Jenkins
Select FreeStyle Project

Build Steps
newman run --disable-unicode C:\Users\Reka\Desktop\New\postman\postman_export_collections\DataDrivenReqRes.postman_collection.json -r htmlextra

Running Postman Collection In Jenkins
Build Success

Conclusion:
I hope, This article will help you to understand How to do Data base Testing in Postman and generate HTML Report and run the Postman Collection in Jenkins .
You can execute Get Request , Post Request , Put Request and Delete Request in Postman .
You must have got an idea on the topics explained in this blog. Lets explore more and learn New Topics.
Happy Learning