Sobes.tech
Middle

Can you tell me more about your experience with WireMock: how did you set it up and use it?

sobes.tech AI

Answer from AI

In my experience, WireMock was used to simulate external HTTP services during automated testing.

WireMock was usually run as a standalone server or embedded in tests via a library. For example, starting a WireMockServer in Java tests:

WireMockServer wireMockServer = new WireMockServer(options().port(8080));
wireMockServer.start();

wireMockServer.stubFor(get(urlEqualTo("/api/data"))
    .willReturn(aResponse()
        .withStatus(200)
        .withHeader("Content-Type", "application/json")
        .withBody("{\"key\":\"value\"}")));

// The code under test makes a request to http://localhost:8080/api/data

wireMockServer.stop();

WireMock was used for:

  • isolating tests from real services,
  • testing handling of various responses (success, errors, timeouts),
  • configuring scenarios with different responses for different requests.

This helped improve test stability and speed, as well as cover cases that are difficult to reproduce with real services.

Can you tell me more about your experience with… - sobes.tech