Overview

Get started today
Replay past traffic, gain confidence in optimizations, and elevate performance.

API mocking plays a critical role in software development to isolate the system under test, reducing dependencies across teams, and streamlining the entire testing process. In this blog, we discuss the benefits, drawbacks, and key use cases for our top 8 mocking tools, including Postman, Hoverfly, Mountebank, MockServer, GoMock, MockAPI, Beeceptor, and Speedscale. Plus, we dive deeper into the various API mocking approaches used by these tools.

 

API Mocking Tools: Our Top 8 Picks

API mocking is the process of simulating external dependencies and API endpoints without actually relying on the live API. It plays a crucial role in software development to isolate the system under test, reducing external dependencies between development and operations teams, maintaining operational continuity, and fostering an agile environment. When executed well, mock API tools streamline the testing process and improves the overall software development lifecycle. API mocking can also involve simulating various error scenarios and latencies to identify potential problems in the early stages of development.

There is a wide range of both free and paid mock API tools available today, and they’re each well suited for different scenarios. When choosing the right API mocking tool for your development team, consider these questions:

  • Does the tool support automatic mock creation, alleviating manual labor?
  • How well does the tool replicate actual service behavior?
  • Does the tool offer a user-friendly interface, making it easier for your team to use? (eg. Does it require you to learn a scripting language?)
  • Does the tool integrate seamlessly with your existing development and testing infrastructure?
API mocking tool considerations

In this blog post, we’ve compiled and evaluated our top 8 mock API tools.

  1. Postman
  2. Hoverfly
  3. Mountebank
  4. MockServer
  5. GoMock
  6. MockAPI
  7. Beeceptor
  8. Speedscale

We also break down 5 mocking methodologies so you can familiarize yourself with the different approaches from tools available.

 

Postman

Postman interface

Pros of Postman

Postman is an “all in one” API platform for building and testing APIs. Its functionality goes beyond just API mocks. Developers can design, mock, debug, test, document, monitor, and publish APIs all from one place, making Postman the “Swiss Army knife” in an API development toolbox.

Consider a scenario where a team is developing a RESTful API. Postman allows developers to design the API, create a Postman mock API server to simulate responses, document the API for future reference, monitor its performance, and finally publish it as a Collection. All of this can be achieved via a user-friendly interface within the same environment.

Creating a mock API server in Postman is a fairly straightforward process. It starts with making requests and saving them to a Collection. Each request should then be executed and the resulting response saved as an example. Once this has been done, the Postman mock API server can be configured by selecting “Mock collection” from the menu next to the collection name.

The mock API server is given a name, and upon creation, provides a URL that can be used to send requests, which will return responses that mirror the examples saved earlier.

postman not found

Advantages of Postman:

  • User-friendly design
  • An API developer’s “Swiss Army knife”

Cons of Postman

Due to its wide array of features, Postman may have a steep learning curve for new users. Postman’s vast functionality can be overwhelming at first, but a lot of teams find that it’s worth the investment to understand the tool. Another disadvantage of Postman is its position as a “Swiss Army knife,” which carries with it the old saying “Jack of all trades, master of none”. For more specific use cases, you may find other tools more suitable.

 

Hoverfly

Hoverfly website

Hoverfly is a lightweight API mocking tool that supports a wide variety of protocols and APIs, including HTTP/S services (REST, SOAP, XML, JSON, and GraphQL).

Hoverfly Pros

Like the rest of the tools in this roundup, Hoverfly aims to provide developers with top-notch DevEx. To achieve this, it uses a client-server approach, which consists of two binaries: the hoverctl command line tool and the Hoverfly app. The former is used to manage the app from your local machine, while the latter provides the proxy server, web server, and API endpoints.

It’s important to note that the developer experience may vary depending on whether you use the open source version, where you will have to deploy Hoverfly on your own local or remote infrastructure, or the hosted solution Hoverfly Cloud, which provides an intuitive UI:

Hoverfly dashboard

You can perform all kinds of tasks from the UI, such as creating simulations, building dynamic responses from templates, capturing real service activities, importing an API from Swagger, adding a mock service, and more. Needless to say, you can also use the command line interface if you prefer.

Regarding scalability and performance, this will depend on which option you choose. Hoverfly Cloud supports up to 2,000 requests per second per service, while Hoverfly open source figures will depend on the capacity of your on-premise or cloud hardware. For your reference, you can install Hoverfly open source on macOS, Linux, Windows, Docker, or Kubernetes.

As you can imagine, when it comes to licensing and pricing, everything will depend on the version you decide to work with.

Hoverfly Cloud offers three plans: the Developer plan at $10/month, the Professional plan at $30/month, and the Enterprise plan. For details on what each plan includes, visit the pricing page.

The open source version uses the Apache License, Version 2.0, which allows you to redistribute and modify the source code at no cost.

Last but not least, an advantage of Hoverfly Cloud over Beeceptor, MockAPI, and Mountebank is that it provides commercial support, consulting, and training, which is essential for complex projects.

Hoverfly Cons

While Hoverfly is a versatile API mocking tool, it’s not without its drawbacks.

On the one hand, it lacks out-of-the-box integrations. Hoverfly offers native language bindings for Python and Java, which partially compensates for this, but at the end of the day, you’ll have to spend time creating your custom integrations.

On the other hand, Hoverfly does not provide the possibility of generating synthetic mock data, populating mock responses with CSV lookup data, or persisting and retrieving values across service calls.

Another missing feature is monitoring, which can really be a deal-breaker when working with complex scenarios.

While Hoverfly provides a versatile environment for service virtualization and API mocking, it may struggle with complex scenarios due to its simplicity. That said, Hoverfly could be ideal for DevOps teams since it excels in rapid development and testing, but it may not be the best option for large projects.

 

Mountebank

Mountebank is a versatile API simulation tool that stands out for its flexibility in supporting protocols beyond HTTP/HTTPS, like TCP and SMTP.

Mountebank Pros

Mountebank calls API mocks “test doubles” or “imposters,” which adds a touch of humor to the developer experience. But don’t underestimate the tool due to its naming convention; it also offers great flexibility, starting with the options it provides to install and manage the tool.

You can install Mountebank locally using npm install -g mountebank, then invoke the tool with the mb command. However, interestingly, you can also opt to use Docker instead, as it gives you control over scalability and performance:

docker pull bbyars/mountebank:2.9.1

docker run –rm -p 2525:2525 -p 4545:4545 -p 5555:5555 bbyars/mountebank:2.9.1 start

You also have some alternative methods for managing API mocks. You can manage Mountebank using curl, which is the default method, or you can use a plugin like Mountebank UI or Disguise if you prefer the convenience of an UI. The following screenshot shows the former:

Mountebank Imposter UI

As you can see, the GUI offers basic functionality that allows you to create collections, create “imposters,” filter by criteria, and more.

You can also configure Mountebank JSON from the UI, as shown below:

Mountebank JSON

Although these UIs are helpful, you should be aware that Mountebank’s advanced functions are configured from the command line. For example, proxies give Mountebank the ability to capture and replay a rich set of API data from your test scenarios.

Regarding scalability and performance, as mentioned, you have the option of using Docker. This gives you an edge over other tools since you gain absolute control over the infrastructure where Mountebank runs. For example, if you use Kubernetes, you can add Mountebank to your development toolkit and thus leverage the incredible scalability and performance benefits of Kubernetes.

Another indisputable strength of Mountebank is the variety of plugins available. From client libraries written in the most popular languages to persistence stores, Mountebank has something to offer for everyone. This includes some community plugins that expand its capabilities, such as LDAP, websockets, GraphQL, and network management protocols like SNMP, Telnet, SSH, and NETCONF.

Mountebank Cons

Despite its many advantages, Mountebank has some weaknesses that you should consider.

For instance, Mountebank does not have a built-in helper to generate mock data, so you will have to find a way to populate mock data.

Furthermore, since Mountebank is free and open source, support could be an issue. As stated in its MIT License, Mountebank is provided “as is,” without a warranty of any kind. This is possibly a deal-breaker for many companies that do not count opening a GitHub issue or asking a question via Google Groups as support.

Another point to keep in mind is that Mountebank does not have built-in monitoring; however, you can pass JavaScript functions through predicate injection. Thanks to this, you can include a logger object with debug, info, warn, and error functions to write API log data.

Mountebank provides developers with a robust REST API with a number of advanced features that make it easy to test microservices and APIs. However, the lack of commercial-grade support and built-in monitoring can be a drawback for many companies.

MockServer

MockServer documentation

Pros of MockServer

MockServer is an open source framework for exclusively mocking HTTP and HTTPS APIs. One of MockServer’s major advantages–and distinct features–is the wide array of deployment options available, including JUnit, Sprint, Node.js, or as standalone servers deployed with Docker or Helm. These options create a lot of flexibility for developers. MockServer is a great choice for developers building a web app with a variety of services, like user authentication, inventory management, and payment processing.

How to mock HTTP APIs with MockServer

Consider a situation where a developer is working on an HTTP-based API for a complex online marketplace. Developers can define detailed requests and responses for each service. This enables thorough testing of each component in isolation, as well as their interplay, without relying on the actual APIs.

Advantages of MockServer:

  • Wide array of deployment options
  • Ability to define detailed requests and responses
  • Good for applications with a variety of services

Cons of MockServer

The same flexibility that makes MockServer a powerful tool can also be one of its potential drawbacks. MockServer doesn’t enforce a specific way of doing things, leaving a lot of decisions up to the user. While this allows developers to tailor the tool to their specific needs and use cases, it also requires a high level of discipline and a clear strategy. Otherwise, there’s a risk of inconsistent usage across different parts of the project or team, which can lead to confusion and inefficiencies.

 

GoMock

GoMock

Pros of GoMock

GoMock is an invaluable tool for Go programmers to create precise and maintainable tests while staying in close alignment with actual service interfaces. It offers a robust framework for creating mock objects, setting up behavioral expectations, and verifying that these expectations are met during testing.

GoMock works by generating mock interfaces from a design-under-test interface. A source file containing interfaces is used as an input, and GoMock generates a “mock” source file with the same interfaces and additional methods for controlling its behavior.

The GoMock experience begins with the creation of an interface for the service that needs to be mocked. For instance, if you have an application that uses a “UserService” for managing user data, an interface needs to be defined that encapsulates required actions such as “GetUser” or “DeleteUser”. Afterward, the mock is generated by running mockgen, a command-line tool provided by GoMock, to create a mock source file. This contains a struct that implements your “UserService” interface and extra methods for controlling its behavior.

How to get started with GoMock

When it’s time for testing, an instance of this mock struct is created and expectations are set, specifying what parameters are expected when methods are invoked, what the mock should return, and how many times a method should be called. When the tests are run, any deviation from these expectations causes the test to fail, accompanied by a descriptive error message.

Advantages of GoMock

  • Aligns closely with actual service interfaces
  • Includes methods for behavior control

Cons of GoMock

While GoMock is extremely helpful for Go developers, it’s language-specific. Thus, it may not be the best option for teams working with multiple languages.

 

MockAPI

MockAPI.io

MockAPI is designed to expedite the process of designing and deploying mock APIs. Its standout feature lies in its simplicity and speed of operation.

A practical use case could be during the early stages of front-end development. If the backend isn’t fully developed, front-end developers may find themselves at a standstill, waiting for necessary APIs. With MockAPI, a mock backend can be swiftly created, bypassing this roadblock and allowing the front-end development to continue seamlessly.

MockAPI also offers a user-friendly interface, further simplifying the process of creating and managing mock APIs. Its drag-and-drop design approach enables even the most non-technical team members to participate in the API design and mocking process, fostering broader team collaboration.

Advantages of MockAPI

  • Designing & deploying mock APIs is simple and fast
  • Easily mocks backends
  • Drag & drop user interface
MockAPI interface

Cons of MockAPI

However, while MockAPI shines in its simplicity and ease of use, it may not cater to more complex scenarios. As a disadvantage, MockAPI’s features are designed for straightforward use cases and might not be sufficient for intricate API mocking needs. If your project requires more complex mocking—such as simulating traffic patterns, intricate response behaviors, or automatic mock generation—you may need to consider other tools that offer more advanced functionality.

 

Beeceptor

Beeceptor website

Beeceptor is a web-based API mocking tool that stands out for its simple approach and balance between pros and cons.

Beeceptor Pros

Beeceptor enhances the developer experience by allowing developers to record API responses and mock them repeatedly. It offers simplified authentication through support for single sign-on (SSO) and lets you inspect incoming payloads and headers. Additionally, Beeceptor resolves cross-origin resource sharing (CORS) complexities by enabling developers to whitelist origins.

Regarding ease of use, Beeceptor has one of the most intuitive UIs. You can create a free mock server by simply assigning a name to your endpoint. Once created, you can start sending requests either using the supplied URL or the curl command:

Beeceptor API mocking

Building a custom mock is also straightforward:

The same simplicity applies to setting up a proxy, creating mocking rules, and more, which is great if you just want to do quick tests on an API that isn’t too complex.

Another notable feature of Beeceptor is its ability to prototype an app using fake data helpers. The process basically consists of creating a mock template that specifies the type of data you want to use, then applying it. For an overview of supported attributes, you can read about generating fake data for a mock API response and using request data to create a dynamic mock response.

Finally, when it comes to licensing and pricing, Beeceptor offers different tiers, ranging from a free plan that offers up to 50 requests per day per endpoint and basic functionality to an Enterprise plan that allows over 1 million requests per month and unlimited users. Additionally, it offers a Developer plan ($10/month) and a Team plan ($25/month), which allow 15,000 and 100,000 requests per month per endpoint, respectively. It’s worth mentioning that the Enterprise plan mentions the option of private cloud deployment using AWS, GCP, or Azure, but the documentation does not provide details on this.

Beeceptor Cons

When it comes to scalability and performance, Beeceptor uses a cloud-based SaaS model. On the one hand, that’s an advantage since you don’t need to install a client or dependencies. On the other hand, you have zero control over its scalability and performance. For reference, the pricing page states that Beeceptor can handle over 1 million requests per month and unlimited users, which may be enough for small to medium projects but insufficient for large-scale API testing. Unfortunately, neither the documentation nor the pricing page shed light on the performance you can expect from the tool.

Regarding support, Beeceptor provides two levels: priority email support for the Enterprise plan and basic email support for the rest of the plans. Additionally, you can send a message to the support team directly. While this level of support is appropriate for independent developers, it’s something to keep in mind if your organization is looking for enterprise-level support.

Beeceptor does not have any integrations, extensions, or plugins. However, it’s relatively simple to implement custom integrations through webhooks and the Beeceptor API. For instance, you could use the Beeceptor API to integrate mocking rules programmatically into your CI tests.

Beeceptor is also somewhat underwhelming when it comes to monitoring. It doesn’t have native mechanisms to track key API metrics. However, you can browse API request logs for any endpoint. Without a doubt, the lack of monitoring features is a disadvantage that can be a deal-breaker for many developers.

Beeceptor is a practical tool for small to medium-sized projects. However, its limited support, lack of monitoring capabilities, and limited scalability do not make it a good option for complex or large-scale projects.

Speedscale

Speedscale interface

Pros of Speedscale

Speedscale’s unique proposition lies in its capability to recreate a nearly identical environment to that of a production system. By capturing and replaying network traffic, Speedscale automatically creates mock APIs, reducing the reliance on external services during testing. Speedscale is built on the principles of production traffic replication.

Service mocking with Speedscale

In a microservice architecture, communication between services, plus a high degree of fidelity and state in mimicking production behavior are essential. Production traffic replication records and stores traffic between users, services, and external dependencies, making it possible to create mocks that replicate actual service interactions. For this reason, it’s ideal for more complex systems.

Understanding the environment where your application will be deployed is critical when considering Speedscale as your mocking tool. That being said, it may be sensible to integrate Speedscale early in the development process and lay the groundwork for truly scalable test automation.

Advantages of Speedscale:

  • Enables scalable test automation
  • Recreates realistic prod conditions
  • Auto generates test environments – no scripting needed

Cons of Speedscale

Speedscale is developed with a sole focus on Kubernetes environments, which may not suit all development teams. Some projects may not use Kubernetes and some may operate on a simpler infrastructure, making Speedscale’s advanced features less necessary.

Top 5 API mocking methodologies

API mocking methods

Understanding these methodologies is crucial for effective and efficient API mocking. While some of these methodologies compete, others are complementary. Most tools are designed with a specific approach in mind, however, you’re often able to customize the approach to fit your needs.

Automatic mock creation

Automatic mock creation reduces the need for manual input, minimizing errors and saving time. It’s best applied in cases where a large number of mocks are required, where manual creation is too time-consuming and prone to error.

For instance, in a microservices environment with numerous service-to-service interactions, automatic mock creation can create the necessary mock services efficiently, freeing developers to focus on other critical areas of development. Or, in highly agile environments with frequent deployments, automatic mocks reduce the otherwise high risk of configuration drift.  Some mocking tools will leverage documentation, request/response message collections (Postman), or API specifications docs such as Swagger or OpenAPI specs to begin the outline of a mock, but they often require filling in data and implementing logic.

Traffic-driven mocks

Traffic-driven mocks utilize real network traffic to generate mock servers, creating a realistic testing environment. This approach using real data shines in situations where the production behavior of the system is critical to understanding how it functions. It’s the closest you’ll get to testing in production without actually testing in production.

Consider a high-traffic e-commerce application that experiences varying traffic patterns during different times of the day. A traffic-driven mock helps simulate these scenarios accurately so you know how the system reacts to different traffic patterns.  Traffic-driven mocks is a new approach, where Speedscale is innovating and other fast followers may develop.

Low-maintenance mocking

Low-maintenance mocking is a methodology that emphasizes minimizing the time and effort spent maintaining the mock servers. The goal is to create complex and highly customized mock services that require minimal updates or modifications once established.

Low-maintenance mocking is effective in scenarios where the system under test has a highly stable interface, meaning that the set of endpoints, methods, request, and response structures rarely change. In a mature, stable system with well-defined APIs that rarely change, these complex, customized mocks can provide a highly accurate simulation of the system’s behavior with minimal maintenance.

However, creating these highly detailed and customized mock servers might be unreasonable for organizations with a large number of services or with services that change frequently. In these scenarios, the effort required to create and maintain such intricate mock servers could outweigh the benefits.

Interestingly, other methodologies like traffic-driven mocking and automatic mock creation can offer solutions to this challenge. By automatically generating mock servers based on recorded traffic or service definitions, these methodologies can provide the benefits of low-maintenance mocks even for large or rapidly changing systems. This way, they enable developers to focus more on the actual development work instead of maintaining a multitude of complex mock servers.

Infrastructure-aware mocking

Infrastructure-aware mocking implements mock servers that are aware of and integrated with the underlying infrastructure. This approach is particularly beneficial in environments like Kubernetes, where the infrastructure significantly impacts the system’s behavior.

Consider a cloud-native application deployed on a Kubernetes cluster. This environment’s unique characteristics, such as pod scheduling, network policies, service discovery mechanisms, and inter-service communication, can all influence application performance and behavior.

With infrastructure-aware mocking, mock servers are often deployed as Kubernetes pods themselves. This offers a significant advantage as it eliminates the need to simulate certain Kubernetes-specific behaviors like network latency or scheduling decisions; the mock servers are subject to the same conditions as the actual services.

For instance, in a microservices architecture deployed within a Kubernetes cluster, you might need to test how service ‘A’ interacts with service ‘B’. With infrastructure-aware mocking, you could deploy a mock of service ‘B’ as a pod within the same cluster. This allows service ‘A’ to interact with the mock just as it would with the real service, including any latency or restrictions imposed by Kubernetes networking policies or pod scheduling.

In this way, infrastructure-aware mocking enhances testing accuracy by mirroring the exact conditions of the production environment. This deeper level of mimicry can unearth potential issues before deployment, reducing live environment risks. This method effectively ‘future-proofs’ applications, ensuring they function optimally within the Kubernetes context. However, while there are many benefits to replicating exact latencies, good API mocking tools also allow you to remove the latency, speeding up responses that are otherwise slow—ultimately leading to faster testing cycles.

Production traffic replication

Replicating production traffic comes with a host of advantages. Firstly, it can provide a more precise and insightful perspective on how your services operate under real-world conditions. By replaying real data in your test environment, your tests become more representative of your live environment.

Secondly, it allows you to simulate unusual scenarios or edge cases that may be hard to anticipate and script manually, but may occur in the actual user interaction with your web app. Consider this use case: Say you have a web app that experiences varying usage patterns based on the time of day or your users’ geographic location. Your service may encounter different loads, data input variations, and perhaps even divergent usage patterns based on cultural practices or local regulations. Replicating production traffic can help simulate these variations, providing a more comprehensive view of how the system behaves under different scenarios. This allows developers to anticipate potential issues better and ensure the service operates effectively under all conditions. It’s akin to a ‘stress-test’ that checks the system’s performance under the exact conditions it will face in a production environment.

Finally, production traffic replication can act as a feedback loop for continual improvement. The data gained from this process can feed into refining the service’s performance, helping you understand how changes to your service impact user experience. This iterative process of testing, learning, and refining ultimately contributes to the delivery of a more robust, efficient, and user-friendly service, affirming the value of production traffic replication as a best practice in API mocking.

 

What is the best API mocking tool?

With the wide range of API mocking tools available, choosing the ‘best’ one isn’t a one-size-fits-all scenario. The right tool will heavily depend on the specific needs and circumstances of your project, as well as what phase of testing you are in. Whether you require the comprehensive traffic-driven mocks provided by Speedscale or the user-friendly interface offered by Postman, your choice should align with your unique project requirements.

If you’re ready to dive into API mocking in a Kubernetes environment, check out our tutorial: How to Mock APIs in Kubernetes. As we continue to innovate and improve upon these methodologies and tools, the process of API mocking will become even more streamlined and efficient, bringing us closer to the goal of smoother, more effective API development.

Learn more about API mocking & service virtualization

PRODUCT

Service Mocking: Avoid staging environments & simulate production

BLOG

Replicate Production Traffic: Record in 1 Environment, Replay in Another

Ensure performance of your Kubernetes apps at scale

Auto generate load tests, environments, and data with sanitized user traffic—and reduce manual effort by 80%
Start your free 30-day trial today

Learn more about this topic