WireMock is a flexible library for stubbing and mocking web services. Unlike general purpose mocking tools it works by creating an actual HTTP server that your code under test can connect to as it would a real web service.
It supports HTTP response stubbing, request verification, proxy/intercept, record/playback of stubs and fault injection, and can be used from within a unit test or deployed into a test environment.
Although it’s written in Java, there’s also a JSON API so you can use it with pretty much any language out there.
WireMock 2.0 is now in development. We’re using the major version bump to make a few breaking changes (but nothing too major, so don’t worry!).
Among the changes we’re making or considering are:
If there’s something you’d like to see added, particularly something involving a breaking change, please post a topic on the mailing list.
If you’d like to raise a pull request (having discussed it on the list first :-) please do so against the 2.0-beta branch, not master.
Some scenarios you might want to consider WireMock for:
WireMock was created and is maintained by Tom Akehurst.
The following people have been kind enough to submit improvements:
Mocking HTTP client classes in a way that adequately reflects their real behaviour is pretty hard. Creating real HTTP exchanges alleviates this by allowing you to use your production HTTP client implementation in your tests.
Object based mocking isn’t really suitable for acceptance/functional testing scenarios. WireMock can be run as a standalone service or deployed into a servlet container to enable it to be installed into your dev/test environments.
Here are some alternative JVM based libraries with similar goals: