In this post, we will learn why we should do API testing.
At a very high level, an application has three components:
- Back end (Data Layer) : Where data is stored and retrieved.
- Front end (Presentation Layer) : User interface.
- Middle ware (Logic Layer) : It connects front end and back end of application.
Let’s understand above point with an example:
You must have heard about Gmail. If you want to create an email id, you visit to Signup page of Gmail where you provide all details like name, age, mobile number etc. You provided details using Front end or presentation layer of Gmail application. Once you enter all details and submit, An API creates a request with data provided by you and hits an end point which creates a new user and stores information to a specific table of database. This API is middle ware. Data provided by end user and credentials details are stored in database. This is back end. You can see how all layers are interconnected using middle ware i.e. API.
As per current development process, maximum functionalities are exposed/built as an API. For example: Consider a hospital application. This application provides below functionalities:
- Register a patient.
- Login to patient dashboard.
- Logout from patient dashboard.
- Retrieve list of patients.
- Delete a patient record.
- Book an appointment.
Developers will develop all these functionalities as APIs which will be integrated by back end and front end teams. When development of application is completed, you start testing. You launch applications front end and provide details to register a patient and find patient is not registered or wrong data is shown or something else. Wow!! You found many defects. Now you will raise them and will be fixed by developers. Front end and back end team will also make some or more changes and once deployed you will test again using UI. It took lot of time, effort and Money. Actually you could have found this defects at very early stage and saved a lot of time, effort and cost. This can be done using API testing.
An API for “Register a patient” will have logic to register a patient and all types of error or warnings if something goes wrong. You can test status, speed and data accuracy of an API independently. Suppose, you need to test “Register a patient” for a different sets of data. You need to keep entering data through front end and you can not cover all those. But API testing makes it easy for you as you don’t require an UI to test API.
You can start early testing and find major bugs at early stage. It will save a lot of time and defects will not move from back end and middle ware to front end. It will increase your application stability and performance.
API testing is beneficial as smoke testing as well. You can quickly check whether all APIs are up and responding quickly and providing correct information. An automated API testing is more powerful.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
Author: Amod Mahajan
My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning