How to use Swagger for API testing

Posted By : Amol Sangal | 04-Sep-2018

Swagger is a software framework, in which so many tools are available to build, design the APIs. Using swagger we can add the web-services also in our codes to talk with Java web services. Swagger is a very helpful framework to test the APIs deeply and properly without feel frustrated.

Basically, using swagger we can perform following operations on APIs -

1. Fetch the data from the backend using the GET method.

2. Insert new data into the database using POST method.

3. Update the already saved data using PUT method.

4. Kill any operation using DELETE method.

5. Status Code & the response codes for each and every API according to their working.

6. Perform end to end testing on the set of APIs.

 

1. GET method – GET method is to get the data from the backend which is already saved inside the database.

Here is an example -

If we want to get the list of all the countries and that is saved inside the database then we’ll use GET method. 

 

  2. POST method – POST method is to add/insert new data in the database.

Like – If we want to successfully log in to any platform then, to test the functionality of the developed API from the developers, we will use POST method.

 

 

3. PUT method – PUT method is to update the already saved data inside the database.

Like – If any user wants to update his / her Password then, an API which is having PUT method will be developed by the developers.  

 

 

4. DELETE method – DELETE method is to kill an operation and user won’t be able to go ahead of the current situation.

Like – If we want to perform LOGOUT operation then, developers will develop an API using DELETE method because it kills the entire operation which is running inside the backend.

 

 

 

5. Status and response Code – It is a very important part of every API that how that is working when it will be uploaded on the HTTP server.

Few basic and most useful status codes are -

100 – Continue

200 – OK

202 – Accepted

301 – Moved Permanently

400 – Bad Request

401 – Unauthorised

403 – Forbidden

404 – Content Not Found

500 – Internal Server Error (ISE)

501 – Not Implemented

502 – Bad Request

6. End to End testing – When a developer writes a code for any operation then he/she write the code for all the possible scenario related to written code which can be used by the end user and if that is required according to the UI design.

To test all the functionalities, Test engineer test all the APIs of the developed controller

(Controller is a set of APIs where we can store the APIs separately according to their working).

 

 

 

 

Related Tags

About Author

Author Image
Amol Sangal

Amol is very disciplined, passionate, and serious for his work. Apart from willing to do learning in new and different domains.

Request for Proposal

Name is required

Comment is required

Sending message..