Mock HTTP Server

Cut your dependencies using a mock HTTP server ๐Ÿ’ป

Create a Mock HTTP Server in Seconds

Using the editor below you can create a simple mock HTTP server that you can use for development purposes.

If you want more features such as multiple endpoints, simulated delays and errors as well as conditional behavior you can sign up to the free trial of Mocki in the top right corner of this site.

What is a Mock HTTP Server?

A Mock HTTP Server is a server that acts as a type of stunt double to a real server. It responds just like the real one but behind the scenes there is no business logic or persistant data storage. This enables you to do things such as switching to a mock http server when your real one is not available. On this page you can read about the many different use cases for a mock HTTP server and what tools are available to support your use case.

Testing Strategies Using a Mock HTTP Server

Finding a good testing strategy is always something you have to think long and hard about. When it comes to integration testing there are many different challenges, some of these are:

Let us dive into these topics and discuss them further.

Test Data

Test data can be a challenge in integration testing since it is not always easy to set up. In some technology stacks it is possible to create scripts to create this data but there is a risk that someone will tamper with it if your environment is left running for a long time. Another option if you have access to create data yourself is to do it manually but that is tedious and error prone. If you do not have access to creating your own test data because of external dependencies for example it might take even longer to get the correct data in place.

Using a Mock HTTP Server you can generate the data that you need so that it is always available. Using Mockis test data generation features you can generate large sets of realistic test data using mock names, e-mail addresses, company names and much more.

This enables you to spend your time on handling that data in the correct way and become independent of external dependencies when it comes to your test data.

External Dependencies

Usually when you have a production application you will have some external dependencies. It might be to an authentication system, an email service or a payment provider. Managing these dependencies and making sure that they work in your test environment can be a hassle. You might have to set up accounts and API keys for each service for every new testing environment that you manage.

To avoid this and only test what you actually want to test, your application, you can create mock http servers instead of these external APIs. These can be run locally with your own configured responses to emulate their real behavior. Using this strategy you will not only avoid setting up test accounts and keys for your external dependencies but you might also speed up the tests themselves since will avoid delays on external HTTP calls.

Load

When you use real services instead of mock servers for your external dependencies you might invoke unnecessary load on them. If you are using a shared environment with integration tests running regularly you are risking parts of your system slowing down or even becoming overloaded by making requests to the real environmeny. By switching your real services to mock servers you can avoid this entirely since they are usually super light weight and do not run on any expensive infrastructure.

Cost

Having multiple environments up and running all the time can mean high costs. Maybe you do not actually need to have all services up and running constantly and can rely on mock servers to take care of parts of all the requests that you tests make? This is a way of saving cost as well as not having to manage as many services at the same time in your environment.

Application Development Using a Mock Server

When developing an application there usually are dependencies between the backend and the frontend. If your backend team is not yet ready developing a new feature but has some idea on how the response will look you can use a mock server in place of the real one. This enables your frontend team to keep working on the new feature while the backend is still not in place. Using this strategy you can accelerate your development and even get early feedback on new backend features before they are released.

Get Started Creating a Mock HTTP Server

There are a number of tools out there that creates a mock HTTP server for you. Our tool Mocki is made for utilizing mock servers at scale for testing and supports use cases such as:

This enables you to support all of the strategies and use cases mentioned in this article. The best thing is we are just getting started. Sign up for our free trial to start building your own mock servers in minutes.