I’m writing some integration tests for a Spring Boot application written in Kotlin. To stub some HTTP requests, I’m using WireMock via spring-cloud-contract-wiremock as dependency. Some anonymized sample code from an integration test: While running these tests on my local machine, everything is working fine. On the CI/CD environment it’s failing though with the following error: I did some searching
Tag: wiremock
Matching JSON request body based on JSON Path with logical operators in WireMock
In WireMock I am trying to match the request based on the JSON body with path matchers as shown below. But it seems that the logical operators are not supported inside matchesJsonPath expression. Is this understanding correct? What could be a possible alternative solution? Any help will be appreciated, thanks! Answer Your assumption is incorrect. You can use operators inside
Wiremock stubbing error: “Unrecognized field “timestamp” (class com.github.tomakehurst.wiremock.common.Errors), not marked as ignorable”
here I come because I have not found any solution to my problem. I’m actually trying to stub a response with wiremock (that call to the Mocked service is be done via FeignClient). My intention is to get a fake response with the real feign client, not in a test, but in the real application. Therefore, In this case, I’m
How to use WireMock’s response template in JUnit 5 Tests
I’m trying to use the Response Templating feature of WireMock, but it does not seem to work with the sample piece of code provided in the docs. This is a sample piece of code: Expected Output: Tests should pass. (meaning the {{request.url}} should be substituted with /test-url as a result of template rendering). Actual Output: Things I’ve tried: Since these
Is it possible to simulate connection timeout using wiremock tools?
I know that it can simulate SocketTimeoutException by using withFixedDelay, but what about ConnectionTimeoutException? Answer Yes it is possible to do this with WireMock by calling addDelayBeforeProcessingRequests(300) against the Java API or posting the following to http://<host>:<port>/__admin/socket-delay: { “milliseconds”: 300 } (Obviously replacing 300 with however many milliseconds you’d like to delay by)