mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.6k stars 1.07k forks source link

Possiblity to reset the request counter for matching request #783

Closed coder-hugo closed 4 years ago

coder-hugo commented 4 years ago

Describe the feature request I'm not sure if this is a bug in the current version or the correct behavior but clearing a HTTP request only removes the matching expectations and logs. The request counter stays the same until you reset the whole mockserver. It would be nice to be able to reset the counter just for matching requests as well.

What you are trying to do I have multiple tests that perform the same HTTP request. If I try to verify that each test has performed this HTTP exactly once all except the first test will fail unless I reset the whole mockserver.

The solution you'd like I'd like to have a way to reset the request counter for matching requests like it can be done for expectations.

jamesdbloom commented 4 years ago

Can you please explain how you are clearing. Can you also explain what you mean by the request counter.

When you clear the logs and expectations for MockServer everything is cleared. The only state that MockServer has internally is logs and expectations. There are is no other state so I don't understand what you mean by request count. Verifications for received requests are done agains the log so if you clear the log the request count for verifications is also cleared.

coder-hugo commented 4 years ago

This is weird. I can not reproduce the behavior any more. We had cases where we needed to invoke the reset method of the MockServerClient to get the verify to work as expected. Unfortunately the non working code doesn't exist in the VCS. So I tried to change/revert the code based of what's in my mind. So maybe I missed something that has caused the issue but now I can reset single requests using the clear method and verify is behaving as expected. Additionally I double checked that we haven't updated mock-server in the meantime. So I'll close this issue. If someday the issue occurs again I'll just reopen the issue and provide a code snippet to reproduce it.