Posts

Showing posts from September, 2016

Integrate Wiremock into Spring Boot Java Web Application for Mocking External Dependencies

Introduction WireMock is a mock server for HTTP-based APIs. Some might consider it a service virtualization tool or a mock server. It enables you to stub out an API or other external dependency you depend on to expedite local development. It supports testing of edge cases and failure modes that the real API won't reliably produce. It also is useful in mocking out external dependencies in unit and integration tests. It has excellent integration with jUnit.

Add Wiremock Dependency First you will want to add the Wiremock dependency. You can download the regular dependency or the fat JAR stand-alone version that contains all it's dependencies. We will be using the standard dependency here. Add the following dependency to your build.gradle

build.gradle dependencies { testCompile('com.github.tomakehurst:wiremock:2.1.12') }

Add Wiremock Unit test Here is the complete unit test that you can use for testing your integration with Wiremock. This unit test uses a jU…