

Mock your HTTP responses to test your REST API - yotsumi
http://www.mocky.io

======
kanzure
Also, python people might be interested in
<https://github.com/gabrielfalcao/HTTPretty> or (bias disclaimer) my
serializer on top of requests+httpretty <https://github.com/kanzure/python-
requestions> for the httpetrified decorator. It loads and mocks an expected
response from a json file in your tests/.

There was a service called requests.in or something that acted like httpbin,
except it gave you a unique url to query against to view multiple requests
over a session. Does anyone know where that went?

~~~
johns
requestb.in

------
untog
It's a nice idea, but relying on a remote service for testing makes me worry.
I tend to mock HTTP responses locally, so that the tests can run when there
isn't even an internet connection available.

~~~
johns
What do you use for your local testing?

~~~
fein
Telnet when I'm lazy or its quick, curl when I actually want to write a full
harness.

------
simons
There's a post here: [http://artemave.github.io/2012/05/27/stub-like-a-
surgeon-spy...](http://artemave.github.io/2012/05/27/stub-like-a-surgeon-spy-
like-james-bond-with-rest-assured/) that talks about using a similar service
(the BBC's REST-assured <https://github.com/BBC/REST-assured>) to aid in BDD
using cucumber.

------
rschmitty
Why not use SinonJS? <http://sinonjs.org/>

Same ability to mock responses and errors, but everything is local. Check your
responses into git and every developer is testing the same stuff, no reliance
on a 3rd party

Makes for lightning fast automatic background testing.

------
memoryfault
Would someone provide an example on how this tool could be used to test a REST
API? I think I'm missing something here. I'm not seeing how a fake response
endpoint lets me test my REST API (shouldn't my test code invoke the API and
validate that the real response was correct?)

~~~
sanderjd
It seems to me that it isn't for testing a REST API but rather for testing
something that _depends_ on one without having to deal with real integration
issues.

~~~
yotsumi
Yes, you explain better than me ;)

------
rco8786
Been working on something similar for local use by running nodejs to both
server static files and mock API responses.
<https://github.com/rco8786/apimok>

------
wilig
For those looking for a local alternative have a look at
<http://wilig.github.io/mockity/>

Full disclosure: I'm the author.

------
donatj
I use <http://frisbyjs.com/> FrisbyJS for most of my front end API testing
needs.

------
gulbrandr
<http://www.hurl.it/>

I recommend this service for this kind of testing.

~~~
quarterto
Hurl is requests. Mocky is responses.

~~~
quarterto
In fact, here is Mocky serving a response to Hurl:
[http://www.hurl.it/hurls/18e4da3bfc0c2159abd1c8e769915c360a8...](http://www.hurl.it/hurls/18e4da3bfc0c2159abd1c8e769915c360a8de8ce/6dc5f86a8ac115dc0870e88cf260d5b7dcb49c15)

~~~
farmdawgnation
If a hurl falls in a forest, and only a mocky is around to hear it, did it
happen?

------
bruth
Nice idea. Are these stored as gists under my account? Can I choose to modify
an existing response so it's versioned?

------
ericmoritz
this isn't any better than using a live server for testing.

Build a good client library for your applications to use, mock the client
library and don't worry about tests failing because of availability problems.

~~~
johns
If the live server has side effects when making the call (send an email,
charge a card, etc) and you just want to test against the response
headers/body, it can be very useful. A local mocking library is also good for
that, but for quicker tests this is nice.

------
rajanikanthr
I use mocking framework(Moq for .NET) to mock my service response and various
xml responses i will save in test xml files.. Anyways, I will try to use it to
test over network rather local mocking

------
gstroup
I prefer to run my own local test server to return mock responses. I built
this little project, that you can install using NPM:
<https://npmjs.org/package/apimocker> It's intended for sandbox development as
well as automated tests. There's no UI, but you can return whatever data you
want. The features are pretty basic right now, but it works well for most
tests, and it's easily configured on the fly.

------
city41
It's a neat idea but I can't imagine I'd ever actually use this for real
testing. Relying on a third party server for your tests can be a problem. We
also have thousands of tests that rely on mocked REST responses, setting them
up with Mocky would be a ton of work.

If Mocky could be ran onsite and had a nice API for easily generating mock
responses, then I think it would be more useful.

~~~
yotsumi
It's an open source project, created 2 days ago. All is possible, this website
is just a proof of concept. And you can fork the project to run it locally.

~~~
city41
Yeah I realize that. I hope I didn't come across too harsh. It is a good idea,
and I'd like to see it grow some more.

------
sinkingfish
I just launched something almost exactly the same a fortnight ago -
e.ndpoint.com - POST/PUT/DELETE support coming soon.

~~~
johns
The URL scheme you're using makes it really easy to view everyone else's
mocks.

~~~
sinkingfish
Yea i'm not looking to obfuscate, I'm planning on introducing user accounts
whereby people by create, save, edit, and alias their mocks. Bypassing that
issue. Anonymous mocks will simply be sequential base62.

------
tjpd
I've heard good things about <http://apiary.io> on this front as well...

~~~
nyam
i'm using it on first project and it's very nice. they let you export your
complete api definition to apiary.apib file which can be parsed with their
github.com/apiaryio/blueprint-parser into json and used with your custom
server localy. it's also nice for synchronizing between devs, when added to
vcs ...

------
aespinoza
This is very cool. It is kind of a fiddler on the web. It is interesting that
I saw something similar but with fiddler in the morning:
[http://www.devcurry.com/2013/05/testing-crud-operations-
in-a...](http://www.devcurry.com/2013/05/testing-crud-operations-in-aspnet-
web_3.html)

------
jnettome
I've sent a pull request to add portuguese brazilian translation. I hope it
helps! Scala is really cool :)

------
alpb
Nice project! My suggestion would be adding JSON editor or JSON syntax
validator for JSON responses saved.

~~~
yotsumi
You already have a light Json editor. The Syntax validation is a very good
idea, thanks!

------
austengary
In case anyone was wondering about licensing:

"[1]DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004

Copyright (C) 2004 Sam Hocevar sam@hocevar.net"

[1] <https://github.com/studiodev/Mocky>

------
nym
You can't mock HTTP responses, the responses mock you.

[http://www.flickr.com/photos/girliemac/6508102407/in/set-721...](http://www.flickr.com/photos/girliemac/6508102407/in/set-72157628409467125/)

------
yotsumi
@misframer The app is updated in real time. So it can be some sporadic errors

~~~
quarterto
Welcome to Hacker News. We don't have @replies here. We do, however, have nice
friendly reply buttons. Great app, by the way!

------
antonpug
How exactly does this work? A short little tutorial would help ^.^

------
meryn
Wouldn't it be better if it would just say "mock your HTTP responses to test
your HTTP client", or "to test your HTTP client code"?

The service makes a lot of sense otherwise.

------
thekingshorses
This failed :(

<div>what</div><div>Not</div>this<ul id="list" data-list="f"><li
class="first">one</li></ul>

------
PuercoPop
Nice, Emacs have a mode for doing the same too:
<https://github.com/pashky/restclient.el>

~~~
yotsumi
Emacs have a REST Client, but this app is like a REST Server: Mocky serve an
HTTP response, whereas RestClient send an HTTP resquest.

------
guyht
I have wanted a service like this forever! Thank you.

------
misframer
I'm occasionally getting hit with

"HTTP/1.1 500 Internal Server Error"

when that's not what I want.

------
rcoh
Ironically, I'm seeing 500s. Great for testing my reliability in the face of
errors!

~~~
yotsumi
Yes sorry for that, I didn't expect a such traffic from HN. Things will be
stable in a few hours :)

------
rross
E.endpoint.com

A very similar offering released a week ago on github.

------
jstoja
That's cool !

