API mocking. Most popular frameworks and libraries

Most popular API mocking frameworks and libraries

This post lists the most popular API mocking tools, libraries and frameworks.

Why we need mocks?

Dependency mocking is a big part of the software development lifecycle in almost every organization.

In order to continuously develop and test applications we have to handle multiple dependency systems which we rely on for integration reasons.

Many times, such dependencies are not under our control. We have no influence how these dependency systems are developed, released or tested.

This is where mocking and specially backend API contract mocking comes to the rescue.

Your team can build and maintain API mocks which behave like dependency systems but are much more stable.

Development Environments

api mocking in development environments

Usually, while developing applications you teams have several environments. Starting with development and team specific environments, other common ones are testing, performance testing, user acceptance, etc.

Development environments are by definition mostly broken and unstable. And they mostly benefit from mocking API dependencies.

Contract First

The main rule for effective API mocking is that mocks should behave like the actual services with reduced funcionality.

In order for this to happen - we have to agree on contract first approach while building APIs. Which means we design contract first, before even building any APIs. This gets among all intertested teams.

OpenAPI specification is the industry standard for API contracts.

This way dependent teams can start their development by mocking API contracts, and teams responsible for API can start to actually build them.

Below we have collected list of tools and frameworks most commonly used to automate API mocking.

API mocking frameworks and tools

  • WireMock - Java based, simple API mock server.
  • sMockin - Java based API simulator
  • Amokjs - lightweight API mocking library, written in JavaScript. Example project.
  • Mockbin - API response generator with cloud based UI.
  • Mocky - simple API response mocking tool, based on Scala.
  • Mockoon - API mocking tool, including nice UI, build with JavaScript and Electronjs
  • Mountebank - is advanced mocking framework. Allows you to create service virtualisation and emulate APIs.
  • Karate - Testing framework, which can be used for creating API mocks.
  • SoapUI Mocks - best known tool for working with SOA type services, it also provided mocking capabilities.
  • Mockapi.io - cloud based API response mock service.
  • Wilma - Service stub and transparent proxy, which allows to capture and analyse API requests.

If you would like to recommend a framework or a tool to be added to above list - let us know.

Similar posts: