Learning every day, sharing every week

TIL: Api Mock Responses in Mobile development

Saidel López
2 min readNov 26, 2018

--

In software development it is common that two different teams to work on the same feature but in different levels. Under this context, it is unavoidable that the development times grows faster due to a team waiting the another to deliver some results to keep on working.

As an Android Developer, sometimes I loose a lot of time waiting for my teammates to finish and test a new server response that I must use right away. Fact is, I can’t blame them. Even the best planning might fail for any reason.

I started to use API Mock Responses, that is, an online alternative to get a false-but-possible response from the actual server I wanted to integrate.

Does it help?

I tried a couple of options to mock responses from server. I know there are a lot more that this list but it might be a good kick start for you to keep on searching for the best tool for you. Some of my suggestions might not be too clever but there are useful for me. So here we go:

  1. Use a static page in pastebin.com: If you’re more experiences as me, you can laugh as much as you can. If not, go to pastebin.com and write your response. This site will provide you a unique URL for that post. Then, to the given URL put the work “raw” in order to get the real content without the site ads and styles. For instance https://pastebin.com/raw/GJbt3BwV is the actual test I put in there.
  2. Write a Gist content inside your personal Github account and follow the same technique as in pastebin. In this case, the raw version of your file is a longer URL but you can see it without any problem. You can create you Gist page as secret to avoid anyone else to see the structure of the response you’re working with. This is a public example of an XML in my personal Github account https://gist.githubusercontent.com/saishaddai/d892a995b7d661c44452ecb7ac7eadd9/raw/ab9557c4adf2753e240fc614fde5d45ea707f7d4/test.xml
  3. Ok, let’s get serious from now on. MockBin, MockServer and Mockable are real tools for mock responses. It allows to custom the kind of responses, the file type, the number of responses and even change the response depending on the request parameters. It also have a pricing plans for more complex behaviour and consuming reporting.

--

--