DETAILED READ SECTION



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.


Maven Dependency


<dependency>

<groupId>com.github.tomakehurst</groupId>

<artifactId>wiremock-jre8</artifactId>

<version>2.24.1</version>

<scope>test</scope>

</dependency>

Basic Usage:


To make WireMock available to your tests on its default port (8080):


@Rule

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:


@Rule

public WireMockRule wireMockRule = new

WireMockRule(options().port(8888).httpsPort(8889));


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:



Exercise 1 Tests:



Exercise 2:



Exercise 2 Tests:


Exercise 3:



Excercise 3 Tests:



Exercise 4:



Excercise 4 Tests:



Exercise 5:



Excercise 5 Tests:



#NGAutomation

Building better QA for tomorrow