API testing using postman

 API TESTING is a software testing type that validates Application Programming Interfaces (APIs). The purpose of API Testing is to check the functionality, reliability, performance, and security of the programming interfaces.

How to do API Testing using POSTMAN ???

prerequisite :

- Postman should be install on your system.

- Basic knowledge regarding postman and API testing.

1) Normal GET Request

  1. Open the postman

  2. Select the GET from the request drop down

  3. Enter the get URL in input “Please enter request URL”

  4. Then click on send 

  5. You will get the response with the status code

2)Normal Post Request

  1. Open the postman

  2. Select Post From the request drop down

  3. Enter the get URL in input “Please enter request URL”

  4. Then Click on body

  5. Select the raw option and select the JSON from the drop down

  6. Then Add the body json 

  7. Then Click on send it will give the response Created with status code 201



3)How to parameterized the request

  1. To use the parameter you need to set the environment

  2. Click on the eye icon of postman screen

  3. Then Click on the edit for set the global variable which can be used in every collection

  4. Then Add the url variable with the request URL 

  5. Then click on the save

  6. Then Go to main screen and create the new request

  7. Select GET from the request type drop down

  8. Now in the Request URL add the {{url}}/users where {{url}} will take the value of the global variable that we have added

  9. Now click on the send and you will get the response with status code 200



4)Steps To create the postman tests

Postman tests are the simple java script code added to the request which help us to verify the response , Like status code of the request , to assert the data of the response etc.

Its starts with pm.test.


Steps to create the postman tests

  1. Go to the existing get request

  2. Click on tests tab

  3. From the snippets click on the status code

  4. Click on send button

  5. Now result of the test will be displayed




5) How to Compare the response actual result with the expected result

  1. Go to the previous request

  2. Go to tests

  3. From the snippets click on “Response body:JSON value check

  4. Replace ‘your test name” with the “check if user with id 2 has name Ervin Howell”
  5. Replace jsonData.value to the path for which you need to perform comparison here it will be jsonData[1].name 
  6. Now in the to.equal() add the name of user with id 2 . So it should be to.eql(“Ervin Howell”)
  7. So test would look like this 
                pm.test("check if user with id 2 has name Ervin Howell", function () {
         var jsonData = pm.response.json();
          pm.expect(jsonData[1].name).to.eql("Ervin Howell");
         });
        8. Click on send
        9. Now result of the test will be displayed

- Hina Murdhani

Comments

Popular posts from this blog

PLAYWRIGHT : Automation Tool

MABL : Codeless Automation Tool

CYPRESS AUTOMATION TOOL

.JAVA to .JAR Conversion

Difference of Opinion on Node vs Go

BlazeMeter : How to write Jmeter script without prior knowledge of Jmeter

Why node-red is use for embedded programming ?

Loadium tool For jmeter script from POSTMAN

Software Testing Life Cycle(STLC)