circleci / bond

spying for tests
127 stars 28 forks source link

Add support for stubbing consecutive calls. #23

Closed sachinpkale closed 7 years ago

sachinpkale commented 7 years ago

Sometimes we need to stub with different return value/exception for the same method call. Typical use case could be mocking iterators. Another use case that I faced is testing retries. For example, we are testing a function which makes a network call and on exception, retries once. For testing, we need to mock the network call with two possible outcomes: first it should throw an exception, next time, it should return expected result.

JustinC474 commented 7 years ago

@sachinpkale thanks for this! really cool feature, we appreciate it.

sachinpkale commented 7 years ago

Thanks @JustinC474 Can we push this change to Clojars?

JustinC474 commented 7 years ago

@sachinpkale just published it - https://clojars.org/circleci/bond

sachinpkale commented 7 years ago

Great! Thanks @JustinC474