API Testing for Effective Regression

Abstract: SOA has become very popular in recent years. APIs are the key to success of SOA applications. Effective automation of APIs translates to organization’s success. This paper demonstrates how API testing led to improved results in regression testing

While using your phone, have you ever wondered why it’s easy to use e-commerce apps and not their sites from the phone browsers? Because mobile applications work best when they are lightweight and faster. And what makes them so? It’s the APIs developed using protocols such as REST.

The meteoric rise in the no of smartphone and tablet users demanded a new way of software delivery. Bulky software was okay to consume on desktops but not on handhelds. Also, delivering software as service enabled a plethora of developers to consume the services and build their applications without having to re-design the common functionality.

I will use a personal experience to explain what this means. My organization has been traditionally producing desktop based applications. In the recent years, we saw a growing demand for mobile applications as more and more customers were using smartphones for their daily business. Since business logic was already coded we wanted to re-use this and build mobile applications. We used REST protocol to develop APIs which were then consumed by our mobile applications. APIs act as a bridge between the business logic in the legacy system and frontend on your devices.

Our developers created a large no of APIs and started using them to build mobile applications. These APIs performed 4 operations:

  1. GET – Perform read operation on a resource and fetch data in the form of XML or JSON
  2. POST – Create a new resource in the system
  3. PUT – Update an existing resource with new values
  4. DELETE – Delete a resource

All that was good and our business problem was solved but we wanted to make sure that when something broke in our system, we were the first ones to know and as early as possible. Calls to APIs return response codes and an optional response body. Defining checks on these two, helps you in asserting whether the functionality is working fine or not.

With Go-to-market in sight and Continuous Innovation as our goal, we decided to automate the API Testing. Because you can’t test the health of 100s of APIs manually on daily basis. We chose to do it with soapUI. It’s an open-source tool to automate SOAP and REST services.

We had multiple teams working on mobile apps for different modules in our product. Each team created a soapUI project and added as many REST Services as developed by their respective teams. With the help of Groovy scripts it was easy to build scenarios. Once the projects were tested and ready we started running them on daily basis. This helped us with the daily view of how different services were performing. It was crucial in providing early feedback.

On the contrary, UI Automation is a tedious and time consuming process. I am not saying UI shouldn’t be automated. Both types of automation are important. But UI automation can wait because, APIs are developed and then the UI. If your APIs are not working, app functionality will be hampered and end users will be frustrated. Also, in comparison to UI scripts, API scripts are easier to build and faster to execute. Because they don’t involve UI elements whose attributes are liable to change.

In the competitive environment of today’s software industry, it’s important to have API automation done. It gives early feedback and is easy to maintain. With that I would like to conclude that API Testing is not an option but a compulsory thing that helps your dev team find out about failing functionality and alerts them at the earliest and gives them sufficient time to work on issues.

References & Appendix

Author Biography

Sagar Mopagar, Senior Quality Specialist

I am a Senior Quality Specialist at SAP Labs India with 9 years of experience in Software Testing. I have worked on Manual, Automation, Functional, Non-Functional testing. I have developed frameworks for automation using Selenium, RestAssured.

THANK YOU!