top of page
  • Writer's picturePrashant Bellad

Should we Test APIs just in Standalone Mode?

Updated: Apr 4, 2023

In today's world, we see a burgeoning of SaaS-based products solving user problems across a variety of domains. Most SaaS products have also realized the importance of providing the same core business function through integration services. This is where APIfication has gained a lot of popularity and traction over recent years. A few of the important advantages companies gain through APIfication of their business functions are:

  • A SaaS product can enable integration with other SaaS products which in turn can result in new customer acquisitions. eg a payroll product like Deel can provide integration with Leave Management System product like Leave Datesand vice-versa

  • Integrate with payment products like Stripe, so then you do not have to write and maintain the payment processing code from scratch

  • Additional revenue stream through API monetization

The above API advantages are good enough to understand why API testing can be critical. Similar to any type of testing, one should keep the API tests as simple as possible and we should avoid testing APIs in a chained order where say API-2 execution is dependent on API-1. This is in line with the principle of keeping the tests independent of each other. Now, actually touching on the subject of this article - should we test APIs just as standalone? or in other words can we add more value through API testing by combining a few of the API calls? Let’s try to understand through a scenario. Use Case: Suppose in an e-commerce application, a user has added a few products as favorites. These favorite products now

  1. Needs to be marked as a favorite on saying the product’s search page and needs to be listed on the checkout, and billing page if the same is not part of the user's cart.

  2. If the user deletes one of the products from the favorites list then the same update should get reflected on the product search, checkout, and billing pages

In above step 2, the delete action happens through DELETE API, and the favorite products are displayed on different pages through different GET APIs like getUserFavorites, getUserFavoritesForCheckoutPage, etc. In the above case, there is always a chance that either of the GET APIs might not be returning the correct list of the user's favorite product lists. These types of functional issues can also be easily caught through API testing by combining the DELETE call with the GET calls and asserting the GET responses accordingly! Note: Here we are not combining the DELETE API testing with the GET APIs testing. Here, through chaining API calls we are focusing more on testing an end-to-end scenario. Thus, when you are covering these types of end-to-end tests through chained APIs, you should also ensure to have separate individual tests for each of these APIs. Value proposition:

  • We can catch such functional issues fast and early in the development cycle through chained API testing than just relying on end-to-end UI testing

  • You can provide more value through your API testing when the tests help in catching functional issues

Are there any other cases where chaining API calls in API testing makes a valid case? You can write your answers in the comment section or shoot an email to Visit, to know more about our services and engagement...

2 views0 comments


bottom of page