-
Notifications
You must be signed in to change notification settings - Fork 142
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
Support multiple capture invocations #139
Comments
Please see https://github.com/marchaos/testdouble.js/blob/master/src/matchers/captor.coffee. This works for me. If there is only one invocation, the captor.value contains the captured value, otherwise captor.value is an array of all calls in the order the occurred. This allows for some backwards compatibility. |
I'm struggling to imagine very many examples where this would be needed. Can you think of a not-far-fetched example? |
It's a common pattern in streaming applications. I have a callback that is called whenever a message is received from a streaming source. In my usecase, I mock multiple messages of different types to ensure the underlying code handles those accordingly. This needs to be occur in 1 unit test as messages come in on batch. In my captor, I catch each processed message and assert that they contain the correct values. |
Okay. I think I can get behind adding a |
Hi Justin, yep that sounds like a plan. Do you want me to create a PR for this? |
Yeah, please feel free |
This landed in testdouble@1.8.0 for anyone keeping score. |
Hey,
I'm pretty sure this currently isn't supported, but it would be nice to allow for captures to capture multiple calls to the same method. See this example of mockito:
http://stackoverflow.com/questions/5981605/can-mockito-capture-arguments-of-a-method-called-multiple-times
I guess the API would need something similar where you can call capture.getAllValues()
The text was updated successfully, but these errors were encountered: