Wiremock is new age technology tool for Service Virtualization to test API Services.
WireMock is a simulator for HTTP-based APIs.Also known as Service Virtualization Tool or Mock Server.
It enables you to stay productive when an API you depend on doesn't exist or isn't complete. It supports testing of edge cases and failure modes that the real API won't reliably produce. And because it's fast it can reduce your build time from hours down to minutes.
At its core it is web server that can be primed to serve canned responses to particular requests (stubbing) and that captures incoming requests so that they can be checked later (verification).
It also has an assortment of other useful features including record/playback of interactions with other APIs, injection of faults and delays, simulation of stateful behaviour.
It can be used as a library by any JVM application, or run as a standalone process either on the same host as the system under test or a remote server.
All of WireMock’s features are accessible via its REST (JSON) interface and its Java API. Additionally, stubs can be configured via JSON files.
Download and Installation
WireMock is distributed in two flavours - a standard JAR containing just WireMock, and a standalone fat JAR containing WireMock plus all its dependencies.
To make WireMock available to your tests on its default port (8080):
public WireMockRule wireMockRule = new WireMockRule();
The rule’s constructor can take an Options instance to override various settings. An Options implementation can be created via the WireMockConfiguration.options() builder:
public WireMockRule wireMockRule = new
In this post, we will create some sample stubs using Wire Mock stubbing capabilities, which can be used in your API Test Automation Projects as per need:
Exercise 1 Tests: