Reasons to use online mock servers

Reasoning

Have you ever been in a situation when you need to create a feature in your app which should make a request to some external web service, but this service is not available yet? Maybe it is down for some reason, maybe it is only temporary or maybe it is simply still in development by your colleagues. What will you do?

Well, you may obviously leave this part of the app and do other stuff. Or while this web service is not available, go drink some coffee, hang out with your friends, take a day off. Sounds good? Unfortunately this is not an option in most of the cases. Everyone is waiting for this feature, your colleague, your manager, scrum master, product owner.

Simple solution

In this situation you have to use so-called mock data. Of course you need to know the information structure, possible properties and values (at least attribute names and their data types), otherwise you really need to leave this app part and go drink a coffee. But if you have information about the web service(s) and what it returns to you, then you can prepare your mock easily. The only decision you still need to make is how to serve this fake data.

Ways to serve mock data

There might be more than 4, but those below are the most popular:

  1. Within the app itself. Just define some variable or method which returns the data you need. This option will require additional coding to simulate this as an external service by adding some design patterns around it, wrapping with promises, timeouts etc.
  2. Within some local file. This option will allow simulating external requests, but probably it is not the best option to leave this dummy information within your app codebase, which leaves a question on how to store it and later share it with your colleagues. The file is static, has only one URL and can’t generate any dynamic data, e.g. some faker or random information. If you need more URLs, more data, you need to manage all of these manually.
  3. From the local mock server. Another good option for generation of the fake API or dummy API servers. Has more options in terms of dynamic URLs and data. Still, it has some downsides, e.g. this is additional software that needs to be installed locally, configured. Again, there might be a problem with sharing data across your teammates.
  4. Using online mock servers. This way of mock data serving might be the best option for you. It does not need any setup, very straightforward in terms of creating dummy API or fake API, test doubles etc. No problems with sharing the mock data with anybody like programmers, QAs, product owners etc. Finally those cloud services may suggest much more interesting functionality for the API mocking and not only.

Summary

So, if I were you, in a situation where you need to deliver your feature that is dependent on the web service which is not available yet, I would go for an online mock server option. It’s the easiest to set up, no previous experience needed, very simple to share. A perfect API for tests option. You might want to start with the QuickMocker – online API mocking tool which is totally free. There are a bunch of alternatives, but so far only QuickMocker provides most all the required tools for API mocking including a live request interceptor, own privately manageable endpoints under your own subdomain name, faker and random data generators, OpenAPI import, RegExp URL paths. As a bonus it allows not only intercepting requests from anywhere, but also you can forward them to your local application which is a perfect solution for webhooks testing. So, give it a try next time you need to get up and running your mock data. Good luck!