API integration and mocking

api mocking tools and frameworks

This post summarises the benefits of using backend service mocks during APIs development. It lists the most popular API mocking frameworks and libraries used across the industry. Read the API mocking tutorial for practical steps.

Why we need mocks?

Mocking is part of software development lifecycle in almost every organization.

Why its so common?

In times of continuos deployment and DevOps practices – automation is the key element of modern software development lifecycle.

Automation allows development teams to utilise the array of software tools to significantly increase the productivity and software quality and faster time to market.

However, in order to continuously develop and test applications you have to handle multiple dependencies.

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

This is where mocking comes to the rescue.

Your team can build and maintain mocks which behave like dependency systems as far as your consumer applications are concerned.

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 dependency mocking.

You should carefully asses what problems mocks are solving in other environments and use mocks there if needed as well.

In environments like user acceptance – mocks are not recommended. As all systems should be running smoothly.

Contract First

The main rule of mocking is that mocks should behave like the actual services.

The common way of agreeing this is to have fixed specifications and contracts between client and the service.

In REST API integration world, this is usually achieved by using OpenAPI specification (previously Swagger).

Such specification document can be version controlled and tracked for any changes. (consumer driven contracts are popular within the industry).

This way, even if the full dependency service functionality is not ready – we can create mocked ones which still correspond to the agreed specification.

Example of such OpenAPI specification can be created in JSON or YAML formats.

API mocking frameworks and tools

Below list has the most popular API integration and 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 API mock 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,  which allows 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.

 

Did you like this post?
Subscribe to our API first monthly newsletter!

4 Responses

  • Great article, I’d like to add a new product I’m working on, restpoint.io

    Restpoint enables to you auto-generate and deploy an API with backend to the cloud from your JSON or OpenAPI, no coding. In no time, have a real working API in the cloud you try out and share with others for feedback.

    Great for mocking, testing or experimenting.

    • Would be interesting to know what technologies you are using under the hood to build API service from OpenAPI?

  • Great article, thanks for listing my app, Mockoon 🙂

Post Your Comment

Your email address will not be published.