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 ???
- Basic knowledge regarding postman and API testing.
1) Normal GET Request
Open the postman
Select the GET from the request drop down
Enter the get URL in input “Please enter request URL”
Then click on send
- You will get the response with the status code
Open the postman
Select Post From the request drop down
Enter the get URL in input “Please enter request URL”
Then Click on body
Select the raw option and select the JSON from the drop down
Then Add the body json
Then Click on send it will give the response Created with status code 201
To use the parameter you need to set the environment
Click on the eye icon of postman screen
Then Click on the edit for set the global variable which can be used in every collection
Then Add the url variable with the request URL
Then click on the save
Then Go to main screen and create the new request
Select GET from the request type drop down
Now in the Request URL add the {{url}}/users where {{url}} will take the value of the global variable that we have added
Now click on the send and you will get the response with status code 200
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
Go to the existing get request
Click on tests tab
From the snippets click on the status code
Click on send button
Now result of the test will be displayed
Go to the previous request
Go to tests
From the snippets click on “Response body:JSON value check”
- Replace ‘your test name” with the “check if user with id 2 has name Ervin Howell”
- Replace jsonData.value to the path for which you need to perform comparison here it will be jsonData[1].name
- Now in the to.equal() add the name of user with id 2 . So it should be to.eql(“Ervin Howell”)
- So test would look like this
Comments
Post a Comment