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
6
votes
2 answers

com.github.tomakehurst.wiremock.client.VerificationException: Expected at least one request matching

I want to create a Stub for an API and want to verify API call and response returned by the server. for that i have implemented WireMock example : import org.junit.Rule; import org.junit.Test; import…
NarendraR
  • 7,577
  • 10
  • 44
  • 82
6
votes
3 answers

How to enable Response Templating on a Wiremock Servlet?

I am running Wiremock on a servlet implementing this project from https://github.com/tomakehurst/wiremock/tree/master/sample-war I am able to deploy this into a Tomcat and its working. Now, I want to enable Response Templating on this server so…
jacobcs
  • 539
  • 5
  • 14
6
votes
2 answers

How to match a wiremock POST request with some optional JSON parameters & any values?

I need to use wiremock to test a POST request that's sending data like this: { "name": "known fixed value", "dateOfBirth": 5123456789000, "email": "known fixed value", "currentDate": any numeric value, "status": any text value…
johncougar
  • 276
  • 2
  • 3
  • 10
6
votes
1 answer

Wiremock mock returning HTTP 500

I am using wireMock and I am getting a consistent response of 500 Internal Server Error even though the stubbed response is 200 OK. If I debug, I see the connection is always closed. Any idea what might be going wrong? Or what I am doing wrong.…
Pavanraotk
  • 1,097
  • 4
  • 15
  • 33
6
votes
1 answer

"Selector loop waiting on select" when running multiple test cases which use wiremock stubs

I'm using wiremock for mocking a web service. I'm using that to provide a service access to some of units that we are testing. So basically we have multiple junit tests which use stubs from wiremock. But when we run multiple tests at once (let's say…
prime
  • 14,464
  • 14
  • 99
  • 131
6
votes
1 answer

Request body matching in WireMock (not JSON/XML)

I am trying to create a API mock with standalone wiremock. The response body depends upon an attribute in the request body. With JSON, I was able to do. Here is sample mapping: { "request":{ "method":"POST", "bodyPatterns":[ …
xploreraj
  • 3,792
  • 12
  • 33
  • 51
6
votes
1 answer

Can WireMock play and record be used at the same time?

I have an application that connect to an external third-party API, and of late the test instance of the API has not been particularly reliable. This stops development progress and turns our build pipelines to red, so I'd like to add an HTTP…
halfer
  • 19,824
  • 17
  • 99
  • 186
6
votes
1 answer

Wiremock URL matching logic

I am trying to compare the abilities of Soap UI and Wiremock using the following requirement (which is realistic enough for most cases in my projects). Goal is to create a mock for a currency price service. The requirements: Accessible at…
dbalakirev
  • 1,918
  • 3
  • 20
  • 31
5
votes
1 answer

How to use WireMock.Net in a Xamarin.UITest project?

My UITest project works well with original web server, but I want to replace it with mock server using WireMock.net. I already used it in a non-UITest project successfully. Here's my code in UI Test project: [SetUp] public void…
VahidShir
  • 2,066
  • 2
  • 17
  • 27
5
votes
2 answers

Wiremock :How to read the stub from a file in wiremock?

Currently I am setting up request and response in my stub through my java code like below. wireMockRule.stubFor(WireMock.get(WireMock.urlEqualTo("/abc/xyz")) .willReturn(WireMock.aResponse() .withBody("Hey") …
5
votes
1 answer

Changing WireMock __files directory

From the docs: To read the body content from a file, place the file under the __files directory. By default this is expected to be under src/test/resources when running from the JUnit rule. When running standalone it will be under the current…
IsaacLevon
  • 2,260
  • 4
  • 41
  • 83
5
votes
2 answers

Can we customize mapping file names in Wiremock?

I am recording the application through Wiremock using JAVA DSL, Do we have the option to customize the mapping file names? instead of getting the filename which is generated from wiremock.. Example: …
Anant patil
  • 161
  • 1
  • 9
5
votes
3 answers

Query Parameter is not getting matched when using WireMock

I am trying to hit the WireMock with following stub but it seems that the query param is not getting matched. Here is the response: Request was not matched …
monty
  • 108
  • 1
  • 2
  • 7
5
votes
1 answer

WireMock keep-alive

I am want to know whether WireMock supports keep-alive by default or I need to set it explicitly somewhere. I have setup a basic WireMock standalone which accepts request and generates a json payload. However when I curl -v the service I do not see…
user1619355
  • 429
  • 1
  • 4
  • 17
5
votes
1 answer

wiremock java api - stub request body in form of form-data (not string, nor json)

As the title says I have to stub a post request with request body in the form of form data. No json, string, or xml. I am using junit and wiremock's java api. I am doing something like the following: …
Yorgos Lamprakis
  • 761
  • 7
  • 16