Why Use API Virtualization?


Below we use API Virtualization and API Simulation interchangeably, as synonyms.

By creating realistic stand-in simulations of real APIs, API Virtualization removes many development and testing obstacles related to API dependencies.

As Gerard Meszaros put it in his book “xUnit Test Patterns: Refactoring Test Code”: “…Sometimes it is just plain hard to test the SUT [System Under Test] because it depends on other components that cannot be used in the test environment. Such a situation may arise because those components aren’t available, because they will not return the results needed for the test, or because executing them would have undesirable side effects”.

API Simulation is a viable solution to those problems – it enables you to get in control of API dependencies. By incorporating API Simulation into the Software Development Lifecycle, individual developers and teams can increase productivity, improve the quality, and reduce the costs associated with the development and testing of new and changed functionality. Regardless of whether the development methodology is an Agile method, Lean, Iterative, or Waterfall – it just works.

Here is a list of some typical problems and situations API Simulation can address:

  • It is very common nowadays for applications to depend on a good number of other applications and components, which in turn have their own dependencies, and so on. What happens during testing when any one of those direct and transitive depended-on APIs is needed but unavailable?
  • Applications may experience the problem of depended-on applications not having enough QA and performance test environments to match the number of environments required for independent testing with predictable results of several parallel development tracks. Planning for and scheduling test environment use can be a challenge and require long lead times. API simlets can provide simulations of the depended-on APIs that are always available and every time with the right test data. Moreover, those API simlets could be hosted in the environment of the System Under Test without the need for a separate environment resulting in infrastructure reduction.
  • How to decouple the delivery of a new API from the development of the API consumers? When developing new APIs using contract-first approach, creating API simlets from the API definitions or from scratch effectively creates stand-ins for code not yet written. This makes it possible to provide API simulations based on sample data and light logic to mimic the future behavior and to get early feedback on the APIs before completely implementing them.
  • How to test the behavior of an application when a depended-on API is slow or unresponsive? Notice that the dependencies of the dependencies can also be the cause for such conditions. An API simulation of the first-degree dependency can inject delay in sending the response back, effectively simulating what can happen in production due to network latency or application slowness.
  • Third-party external APIs are outside of an application’s control. Using API Simulation can lower the cost, even eliminate pay-per-transaction fees in non-production environments, and overcome the rate limiting that most 3rd-party APIs enforce.
  • In large and small-scale developments alike, testing should start with the developers – developers writing and executing unit tests in isolation; ideally, they will also be executing tests integrated with the depended-on components and applications. The usual approach is to rely on mocks and stubs but one of their limitations is that their use does not go beyond development or build server environments. What if we were to simulate the APIs of depended-on applications and components once and then reuse the API simlets in all non-production environments, including on developers’ laptops and in build server environments?
  • Development efforts are frequently constraint by shared resources like message-oriented middleware or databases. It is impractical, for example, to provide a message queue for every developer. Shared databases in non-production environments can become point of contention and lead to unpredictable and unreliable test results. In number of cases, API Simulation can remove constraints due to shared resources.

The bottom line is that API Simulation makes it possible to get in control of API dependencies. Developers, testers, and managers should seriously look into API Simulation as an enabler for injecting agility into the software development lifecycle, lowering costs, reducing testing times, mitigating release failure, and many other tangible benefits.

 

<< What is API Virtualization? How to Virtualize APIs? >>