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.54k stars 1.06k forks source link

Verifying multiple requests made during one call #29

Closed leggebroten closed 10 years ago

leggebroten commented 10 years ago

Hi,

My code under test makes more than one http call.

I've set up expectations so that the code under test is performing as expected but I can only pass one request to verify (mockServer.verify(request()...)

I can successfully verify the first request, but no others.

Am I missing something?

-Lee

jamesdbloom commented 10 years ago

I assume you have you tried calling the mockServer.verify(...) method multiple times?

As I understand the list of requests you can query should only get cleared if you call mockServer.clear(...) or mockServer.reset().

If that doesn't work when your calling it multiple times that is a bug which I can fix. If this is the case please send me as much context as possible so that I can make sure your use cases have tests that cover them.

In addition I could extend that function so that it has a varargs and can take multiple reuqests to verify as follows:

public MockServerClient verify(HttpRequest httpRequest) throws AssertionError

I'm doing a new release within the next week and I should be able to add this into the release.

Cheers,

James

leggebroten commented 10 years ago

James,

Thanks for the quick response.

Yah, I’ve tried calling multiple times. Perhaps I did something wrong but only the first call to verify works … regardless of which request I’m verifying.

I’ll keep digging.

Thanks for the tool btw !!!

-- Lee

From: James D Bloom notifications@github.com<mailto:notifications@github.com> Reply-To: jamesdbloom/mockserver reply@reply.github.com<mailto:reply@reply.github.com> Date: Wednesday, April 9, 2014 at 1:03 AM To: jamesdbloom/mockserver mockserver@noreply.github.com<mailto:mockserver@noreply.github.com> Cc: Lee Eggebroten leggebroten@backcountry.com<mailto:leggebroten@backcountry.com> Subject: Re: [mockserver] Verifying multiple requests made during one call (#29)

I assume you have you tried calling the mockServer.verify(...) method multiple times?

As I understand the list of request you can query should only get cleared if you call mockServer.clear(...) or mockServer.reset().

If that doesn't work when your calling it multiple times that is a bug which I can fix. If this is the case please send me as much context as possible so that I can make sure your use cases have tests that cover them.

In addition I could extend that function so that it has a varargs and can take multiple reuqests to verify as follows:

public MockServerClient verify(HttpRequest httpRequest) throws AssertionError

I'm doing a new release within the next week and I should be able to add this into the release.

Cheers,

James

— Reply to this email directly or view it on GitHubhttps://github.com/jamesdbloom/mockserver/issues/29#issuecomment-39934360.

leggebroten commented 10 years ago

I screwed up.

Not sure how yet but …

I made multiple calls then verified them.

Sorry ‘bout the false alarm

-- Lee

From: James D Bloom notifications@github.com<mailto:notifications@github.com> Reply-To: jamesdbloom/mockserver reply@reply.github.com<mailto:reply@reply.github.com> Date: Wednesday, April 9, 2014 at 1:03 AM To: jamesdbloom/mockserver mockserver@noreply.github.com<mailto:mockserver@noreply.github.com> Cc: Lee Eggebroten leggebroten@backcountry.com<mailto:leggebroten@backcountry.com> Subject: Re: [mockserver] Verifying multiple requests made during one call (#29)

I assume you have you tried calling the mockServer.verify(...) method multiple times?

As I understand the list of request you can query should only get cleared if you call mockServer.clear(...) or mockServer.reset().

If that doesn't work when your calling it multiple times that is a bug which I can fix. If this is the case please send me as much context as possible so that I can make sure your use cases have tests that cover them.

In addition I could extend that function so that it has a varargs and can take multiple reuqests to verify as follows:

public MockServerClient verify(HttpRequest httpRequest) throws AssertionError

I'm doing a new release within the next week and I should be able to add this into the release.

Cheers,

James

— Reply to this email directly or view it on GitHubhttps://github.com/jamesdbloom/mockserver/issues/29#issuecomment-39934360.

jamesdbloom commented 10 years ago

No problem, perhaps I'll change that argument anyway to make it a varargs as I believe it should be pretty simple and it might provide more flexibility.

leggebroten commented 10 years ago

Agreed.

-- Lee

From: James D Bloom notifications@github.com<mailto:notifications@github.com> Reply-To: jamesdbloom/mockserver reply@reply.github.com<mailto:reply@reply.github.com> Date: Wednesday, April 9, 2014 at 1:27 PM To: jamesdbloom/mockserver mockserver@noreply.github.com<mailto:mockserver@noreply.github.com> Cc: Lee Eggebroten leggebroten@backcountry.com<mailto:leggebroten@backcountry.com> Subject: Re: [mockserver] Verifying multiple requests made during one call (#29)

No problem, perhaps I'll change that argument anyway to make it a varargs as I believe it should be pretty simple and it might provide more flexibility.

— Reply to this email directly or view it on GitHubhttps://github.com/jamesdbloom/mockserver/issues/29#issuecomment-40005988.