Questions tagged [wiremock]

Library used for stubbing and mocking web services.

Wiremock is a library written in Java by Tom Akehurst. It is used for stubbing and mocking web services. 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.

For more information see http://wiremock.org

894 questions
5
votes
2 answers

Android:Espresso:WireMock java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/io/Resources;

Android Studio 3.2. I want to use WireMock in my Espresso's test. In build.gradle buildscript { ext.KOTLIN_VERSION = '1.3.21' ext.ESPRESSO_VERSION = '3.2.0-alpha02' repositories { google() jcenter() } …
Alexei
  • 14,350
  • 37
  • 121
  • 240
5
votes
1 answer

Unit Testing - Wiremock verify failing with connection error

I'm testing a spring-boot application and using wiremock stubs to mock external API. In one test case I want to make sure that my stub gets called exactly once but it's failing with connection error. My Test…
Avv
  • 555
  • 1
  • 10
  • 18
5
votes
2 answers

Adding wiremock extension in docker-compose

I am using docker-compose in my project and spinning up the rodolpheche/wiremock image like below wiremock: image: rodolpheche/wiremock ports: - "xxxx:xxxxx" volumes: - ./src/wiremock:/home/wiremock Now I want to add some random body…
Manoj Kumar
  • 68
  • 1
  • 7
5
votes
2 answers

Java Wiremock - mock external server during testing

Suppose the application is dependent on a REST service on a external server, http://otherserver.com. For testing, I would like to simulate the external rest call (via Wiremock) within a JUnit environment. Starting a seperate server consumes time and…
tm1701
  • 7,307
  • 17
  • 79
  • 168
5
votes
1 answer

How configure WireMock to use https (and a random port)?

I tried to set wiremock to run https on a random port: @Rule public WireMockRule wireMockServer = new WireMockRule( WireMockConfiguration.wireMockConfig().dynamicPort().dynamicHttpsPort() ); but when I use this and I call…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
5
votes
0 answers

How to make wiremock stateful behaviour thread-safe?

I am new to wiremock and I am using the wiremock JSON mappings to test some of the scenarios in my project. In one of the test scenarios, I need to give response 200 OK after 2 retries(500) to the server which is trying to access one of the JSON…
5
votes
4 answers

Spring Boot Integration Test with WireMock and Eureka fails with "No instances available"

When writing an integration test for a Spring Boot application (Service A) that uses a RestTemplate (and Ribbon under the hood) and Eureka to resolve a Service B dependency, I get a "No instances available" exception when calling the Service A. I…
derSteve
  • 751
  • 3
  • 8
  • 20
5
votes
3 answers

WireMock: How to mock file download process?

I'm new inWireMock. I am running the WireMock server as a standalone process. I am able to mock simple rest api, by configuring json files under /mappings folder. Now, I want to mock a file downloading end point. How can I do that? I don't know if…
Manoj Shrestha
  • 4,246
  • 5
  • 47
  • 67
5
votes
1 answer

WireMock: Stubbing - How get object "testClient"?

I want to test http request/response. So I use WireMock. I want to stub response for specific request: Here code: public class WireMockPersons { @Rule public WireMockRule wireMockRule = new WireMockRule(8089); @Test public void…
Alexei
  • 14,350
  • 37
  • 121
  • 240
5
votes
3 answers

WireMock fails with NoSuchMethodError HttpServletResponse.getHeader

I'm trying to use WireMock in my JUnit tests to mock calls to an external API. public class ExampleWiremockTest { @Rule public WireMockRule wireMockRule = new WireMockRule(9999); @Before public void setUp() { …
toniedzwiedz
  • 17,895
  • 9
  • 86
  • 131
5
votes
1 answer

Android Tests don't run on a device lower than 5 (API 21) NoClassDefFoundError

I am trying to run Instrumental tests for my project. But they don't run on devices(emulators as well) that have version lower than 5 (API 21). I have been trying to solve this problem, but still facing with it. I get following exception. 02-15…
user7568246
5
votes
1 answer

Mocking server results on Android (Wiremock, MockWebServer etc)

Does anyone have a full and recent tutorial or project on recording server responses- get and post and headers as needed AND Playing them back with wiremock and/or mockwebserver? I've looked at many out there already
nAndroid
  • 862
  • 1
  • 10
  • 25
5
votes
4 answers

Make wiremock accept any certificate

I have defined a https stub in wiremock as follows:- public class HttpsMockMain { public static void main(String[] args) { WireMockServer mockServer = new WireMockServer(56789, 8443); addStub(mockServer); …
tuk
  • 5,941
  • 14
  • 79
  • 162
5
votes
1 answer

Mocking Http Server responses using WireMock. FileNotFoundException

Just started using wiremock and come across a scenario where i want to stub a GET request with a specific json response. When appending the json to the expected response with; .withBodyFile("product.json")) I get the exception…
L-Samuels
  • 2,712
  • 9
  • 34
  • 42
4
votes
2 answers

Disable logging of WireMock

I'm using @AutoConfigureWireMock(port = 0) to init mock server. This is the setup class written in Kotlin: @AutoConfigureWireMock(port = 0) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, ) class MockServerBase { …
Deqing
  • 14,098
  • 15
  • 84
  • 131