Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using WireMock how can we verify that a request of a given url has NOT been made?

Tags:

java

wiremock

Given the following unit test, I can easily test if a request of a particular url has been made. Is there a way to do the opposite, verify that a request of a particular url has NOT been made?

i.e. verify that a request was made:

stubFor(post(urlEqualTo("/login")));

webclient.submit(testLogin);

verify(postRequestedFor(urlMatching("/login")

What I'd like to do - Verify that a request was NOT made:

stubFor(post(urlEqualTo("/login")));

webclient.submit(testLogin);

verify(postRequestedFor(urlNotMatching("/login")
like image 405
TyrionWebDev Avatar asked Jan 24 '18 22:01

TyrionWebDev


1 Answers

did you try

verify(exactly(0), postRequestedFor(urlEqualTo("/login")));

Basically checking if exactly 0 calls were made. To read more about it. see here

like image 68
best wishes Avatar answered Sep 19 '22 12:09

best wishes