The Role & Relevance of API Testing in an Agile World

Sunny Gupta
Picnic Engineering
Published in
5 min readFeb 28, 2017

--

In the last few years, it’s clear that we’ve seen an exponential increase in the development and use of web-based APIs. It’s commonplace to see applications, websites, services, and databases being loosely coupled and communicating via RESTful (Representational State Transfer) HTTP interfaces.

Colossal monoliths and legacy code are both desolate ruins of a bygone era, as big organizations steadily migrate across to micro services and service-oriented architecture (SOA).

As a population we’re connected to the world like never before in history. In this astonishing age, we have the benefit of uninterrupted access to a vast reservoir of information. This information is currently at our fingertips, and is increasingly close to us through advancements in voice-activated audio and virtual reality.

Arguably, the primary influential contributor to this seamless connectivity is API programming.

About API

So, what exactly is API? Let’s introduce the concept before analysing its impact on the world.

API is software programming which is written to function as a communication bridge between two different applications. It’s a means of exposing or sharing data on an agreed format (e.g. JSON, XML). API also enables the receipt of data from any third party application.

Usually, API works in a similar way to how any website functions. A request is made from the client to the server, and we receive the response through the HTTP protocol.

In a broad sense, the API of a web application makes its services accessible to an entire world of outside developers. This makes it possible for developers to create and launch their own product on top of it. For example, Facebook, Twitter, and Google share their APIs for developers to use as a base from which to build innovative new products. Slack, MailChimp, Dropbox, and many other leading applications also oblige.

Google Maps has been one of the most important API releases of modern times. Countless businesses have exploited this opportunity to create full products, or to incorporate the most comprehensive map platform on the planet within the features of their applications (customer-facing and internal).

Picnic has done the same, by using Google Maps API for our real-time delivery map feature. As we highlighted at in this recent article, the process was far from straightforward!

Overall, API forms a solid foundation for many developers, and acts as boost to the shared B2B economy.

API & Software Testing

Over the past decade, an increasing number of businesses have been moving to API-based development. Inevitably, this requires a change in testing strategy, and a shift in technical processes.

As Agile Development becomes the standard within many organizations, and due to the advancement of CI/CD tooling, the methods by which we develop software and automate testing has changed dramatically.

With more applications adhering to SOA architecture, there’s often a requirement to test the API level separately. This obtains the maximum confidence in a critical layer (business layer), as soon as possible. It also enables the development team to build on solid foundations from the beginning. Generally, it’s not possible to test all API business logic through the user interface.

The Advantages of API Testing

Let’s analyse some of the primary advantages of API testing.

Early feedback:

It’s universally accepted that issues are more expensive and time-consuming to fix in the later stages of a systems development life-cycle (SDLC). API testing engages the testing team early in the cycle, and they can undertake testing activities without the graphical user interface (GUI) being complete. Furthermore, this removes the dependency on the release cycles of frontend teams.

Defines Automation Strategy:

Mike Cohn, the author of Succeeding With Agile, developed the concept of a test pyramid, which you can see below. It places emphasis on the fact that you should have significantly more low-level unit tests than high-level, end-to-end, tests running through a GUI.

Unit tests lie at the base of the pyramid, which are written against the code. These are most likely written by a developer and integrated with CI/CD tools such as Jenkins, TestNG, Mockito, etc

The second layer of tests are API tests. These are executed against the service layer or business layer.

And stretching to the top of the pyramid we see the UI tests. These validate the application as a whole, at the presentation layer.

As we elevate up the pyramid, the costs related to a number of things increase; the creation and maintenance of a test, the test execution time, the test fragility, and the test coverage.

Indeed, UI tests are expensive to make, and in many cases are unreliable and somewhat flaky. On the other hand, UI is subject to a lot of change over the course of time, and requires significant work and maintenance. In a nutshell, this is why API automation should be a part of test strategy for every business that wishes to develop and implement effective automation.

Reduced manual regression:

Agile Development advocates shorter sprint cycles, and less time-to-market. This leads to higher chances of regression, due to the below reasons:

  1. Multiple teams involved in the development across frontend and backend teams.
  2. Different release cycles.
  3. Multiple moving parts.

Test automation has become a critical factor in maintaining agility. Therefore, it is necessary for agile teams to increase their level of API testing, whilst decreasing their reliance on GUI testing

Summary

In the modern world of applications, API testing is a critically important part of the process. It can enable thorough testing success, independent of the application’s UI. In turn, this significantly increases the quality of the end-product, and ensures that the foundation of multiple applications is functionally correct at the earliest stages of development.

API testing can be completed by developers or testers, and there are many open source and enterprise tools available on the market. Some examples include SoapUI, HP UFT, Postman, and Parasoft. There are many other options out there, of course.

Your choice of tool depends on a multitude of factors, including:

  1. The type of APIs you need to test
  2. Your budget
  3. The technology stack of applications and architecture

At Picnic, we’re building a great online shopping experience, and our product reliability is at the heart of this mission. This approach currently focuses on our last-mile delivery, which requires the seamless integration of frontend systems with various warehouse and supply chain backend systems.

To achieve this, we would start with all our core processes running in a shadow environment. This means that any point of failure can be identified and fixed quickly, with minimum disruption and a sensible resource investment. API testing is a key ingredient in developing this ideal test automation.

The maintenance of a great product after launch is key to the long-term success of your business, especially when there are multiple feature release phases over time. The rigorous and regular testing of APIs will enable the sustainable growth of your user base, whilst ensuring an efficiency of work for your testing and development team.

--

--