Skip to content

Implement StrictClient that expects a sequence of requests #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
localheinz opened this issue Jun 5, 2019 · 5 comments
Closed

Implement StrictClient that expects a sequence of requests #41

localheinz opened this issue Jun 5, 2019 · 5 comments

Comments

@localheinz
Copy link
Contributor

localheinz commented Jun 5, 2019

Q A
Bug? no
New Feature? yes
Version n/a

Actual Behavior

Currently, when using the Client and configuring matchers using on()

This is fine, but what if we expect a specific sequence of requests to be sent with matching responses? If we use use the Client as it is right now, it's of course possible to define such a sequence.

However, the order in which request are sent does not matter.

What do you think about introducing a StrictClient, that allows specifying an exact sequence of matchers, and that

  • allows introspecting in the assert phase whether all expected requests have been sent (the (the sequence has been completed)
  • throws a specific exception in the act phase when - given a configured sequence of requests - an unexpected request has been sent

I think this could also nicely cover #36.

What do you think?

Possible Solutions

I would of course propose a PR if you think such a feature would be a nice addition.

🤓

@localheinz localheinz changed the title Implement Client that expects a sequence of requests Implement StrictClient that expects a sequence of requests Jun 5, 2019
@localheinz
Copy link
Contributor Author

localheinz commented Jun 5, 2019

Just thinking, at least some of the behavior could be implemented with the current Client implementation by using assertions in RequestMatcher::matches().

@dbu
Copy link
Contributor

dbu commented Jul 2, 2020

@localheinz did the implementation you use in your project prove useful? you had closed #42 after opening, saying you want to try it out a bit more...

@localheinz
Copy link
Contributor Author

@dbu

It worked well in that regard that tests failed when

  • requests where not sent out in the expected order
  • not all requests where sent out

However, when the StrictClient threw exceptions, then, it was not easy to find out why. I had to var_dump() the actual request and the request matcher, then.

@localheinz
Copy link
Contributor Author

I'll close this for now.

@dbu
Copy link
Contributor

dbu commented Jul 2, 2020

thanks. feel free to open it again if you have further ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants