circleci / bond

spying for tests
127 stars 28 forks source link

Add support for stubbing consecutive calls. #27

Closed JustinC474 closed 7 years ago

JustinC474 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.