Spurious failure with "request was unmatched by any stub matching" since upgrade to WireMock 2.9.0
See original GitHub issueWithout changing any of our own code, updating from WireMock 2.8.0 to 2.9.0 causes many tests to fail with spurious “unmatched request” errors.
Example test:
@Test
public void testAuditLogRequestHeader() throws Exception
{
callingOurStuffHere();
verify(postRequestedFor(urlEqualTo("/1/team/log/get_events"))
.withHeader("Authorization", WireMock.equalTo("Bearer " + TOKEN))
.withRequestBody(equalToJson("{}")));
}
Failure text:
com.github.tomakehurst.wiremock.client.VerificationException: A request was unmatched by any stub mapping. Request was:
at com.github.tomakehurst.wiremock.client.VerificationException.forUnmatchedRequests(VerificationException.java:92)
at com.github.tomakehurst.wiremock.junit.WireMockRule.checkForUnmatchedRequests(WireMockRule.java:90)
at com.github.tomakehurst.wiremock.junit.WireMockRule.access$000(WireMockRule.java:34)
at com.github.tomakehurst.wiremock.junit.WireMockRule$1.evaluate(WireMockRule.java:74)
at com.acme.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
at com.acme.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
at com.acme.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
at com.acme.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
at com.acme.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
at com.acme.common.test.rules.Timeout$CustomFailOnTimeout$StatementRunner.run(Timeout.java:137)
at java.lang.Thread.run(Thread.java:745)
The odd thing is how it doesn’t actually print out anything…
This appears to occur consistently for tests using verify(postRequestedFor(...))
but tests using stubFor(post(...))
still pass.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10
Top Results From Across the Web
Spurious failure with "request was unmatched by any stub ...
Without changing any of our own code, updating from WireMock 2.8.0 to 2.9.0 causes many tests to fail with spurious "unmatched request" errors....
Read more >Wiremock error: Request was not matched as there were no ...
com.github.tomakehurst.wiremock.client.VerificationException: A request was unmatched by any stub mapping. Closest stub mapping was: <Click ...
Read more >Expected == Actual: error reporting problem? - Google Groups
com.github.tomakehurst.wiremock.client.VerificationException: A request was unmatched by any stub mapping. Closest stub mapping was: ...
Read more >Verifying whether specific HTTP requests were made | WireMock
All requests received by WireMock since the last reset can be fetched, along with additional data about whether the request was matched by...
Read more >Wiremock postrequestedfor - Marogal
By default, WireMock will use the most recently added matching stub to ... to 2.9.0 causes many tests to fail with spurious "unmatched...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK, so you’re not actually creating any stubs here. WireMock’s default behaviour is to fail your test if you’ve made requests that it hasn’t been able to match, on the assumption that this probably means you’ve missed something. This is analogous to the approach some object mocking tools take where unexpected calls are considered errors.
Two options to fix this:
failOnUnmatchedRequests
to false in the rule constructor.I’ve ended up updating all the tests using verify to use stubFor instead, and they’re passing, so I’ll just close this. Thanks for the info.