Skip to content
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

Need to be able to mock sequential returns #68

Closed
dcorbin opened this issue Apr 3, 2014 · 4 comments
Closed

Need to be able to mock sequential returns #68

dcorbin opened this issue Apr 3, 2014 · 4 comments

Comments

@dcorbin
Copy link

dcorbin commented Apr 3, 2014

I have a method that takes no arguments, and returns something (potentially) different with each call. willReturn: seems to only return the last thing the mock was configured with for each call. I even tried chaining willReturn method calls (similar to what Mockito does here: http://2min2code.com/articles/mockito_intro/stubbing_method_sequential) to no effect.

@jonreid
Copy link
Owner

jonreid commented Jan 3, 2015

And you shall have it. 36680ec

@jonreid jonreid closed this as completed Jan 3, 2015
@jonreid
Copy link
Owner

jonreid commented Jan 3, 2015

Would you also be interested in a shorthand method, so you didn't have to do all the chaining? Like

[given([mockObject someMethod]) willReturnValues:@[@"foo", @"bar", @"baz"]];

@jonreid jonreid reopened this Jan 3, 2015
@jonreid
Copy link
Owner

jonreid commented Jan 4, 2015

On second thought, let's not do the shorthand, at least not yet.

@jonreid jonreid closed this as completed Jan 4, 2015
@dcorbin
Copy link
Author

dcorbin commented Jan 4, 2015

I think the situation is uncommon enough that the short hand method is not worth it anyway.

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

No branches or pull requests

2 participants