API Testing

27 April 2016 by Sonali Sorte No comments

Hi friends, today we are going to discuss API Testing. While testing, lots of time we came across the words request, response, output etc. These words have predefined meaning. We will go step by step to know about API Testing.

What is API?

API is “Application Programming Interface”. API mainly used for data communication between two modules or systems. A source sends a request to destination and destination sends a response to the source using API.

API

Types of API’s :

REST and SOAP are the types of API’s. Most of the times developer choose to go with REST API structure style. REST is lighter than SOAP.

REST :

REST is “Representational State Transfer”. REST is an architecture style while SOAP is a protocol. REST based web services use URI. URI is “ Uniform Resource Identifiers. REST web services are in resource structure architecture. The resource would be a chunk of respective information e.g. User id, profile etc.

Rest uses simple HTTP calls to access resources. The application sends a request to another system/backend/module and the destination will send a response to the application.

How RESTful service works?

RESTful services use HTTP verbs to determine the which operation to be performed.

GET method: To get an information
PUT method: To update an information
POST method: To create an information
DELETE: To delete an information

Let’s take an example of how REST API works.

There are lots of tools available like Postman, Poster etc to verify request and response. Here I am using Charles tool. Using this tool user can send a request and test the desired output is coming or not. Also, a user can edit the request with test data as an input and test the desired output with respect to given input.

To use Charles you need to put “Request URL” in the browser tab (Request URL can be taken from -> Inspect header element by hitting the desired URL). Refer below screenshot.

screenshot

Charles Session for the Desired request:

Charles session screenshot

If you want to edit the request you need to right click on the request and provide desired input and click on execute. After execution check for desired output.

SOAP:
SOAP is “Simple Object Access Protocol”. SOAP is the XML based protocol used for connecting the application with the backend. SOAP API is language independent platform. It must be parsed before use as it uses XML formatting.

For SOAP, the testing user must give a file in WSDL format. WSDL is: “Web Services Description Language”. The user can use SOAPUI tool for testing SOAP API.

Prerequisites:

SOAPUI Link: https://www.soapui.org/downloads/soapui.html
WSDL file for API: Sample WSDL file for test / to get start off: https://www.soapui.org/getting-started/your-first-soapui-project.html

Let’s take an e.g. In SOAPUI, we need to add desired WSDL file which we want to test.
Steps:
Install SOAPUI tool
Click on ADD new Project
Right-click on the project and then Add desired WSDL file and click on ok.

After adding necessary prerequisites, click on SOAP and provide desired input XML for appropriate output.

Reference: https://www.soapui.org/soapui-projects/soapui-projects.html

soap UI

Hope this information helps you. Wishing you a very happy API Testing.

Author: Omkaar Deshpande
Email : omkaar@idyllic-software.com
Linkedin: https://in.linkedin.com/in/omkaar-deshpande-63a9001a

Sonali Sorte

Follow me on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Blog

Get access to proven marketing ideas, latest trends and best practices.

Next up home

Contact

Lets build cool stuff

Share your contact information & we will get in touch!

I want (Tell us more about your dream project)