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

Allowing multiple return values for a mock method #714

Closed
davidfragalaureano opened this issue Apr 25, 2022 · 2 comments
Closed

Allowing multiple return values for a mock method #714

davidfragalaureano opened this issue Apr 25, 2022 · 2 comments
Labels
waffle-mock-contract Anything related to the mocking package

Comments

@davidfragalaureano
Copy link

davidfragalaureano commented Apr 25, 2022

Following the example for mockito in Java:

when(mockFoo.someMethod())
        .thenReturn(obj1)
        .thenThrow(new IllegalArgumentException())
        .thenReturn(obj2, obj3);

Is it possible to have a feature that lets us return different values each time a mock method is called?

Perhaps something that can be chained as above:

await mockContract.mock.someMethod
            .returns(someValue)
            .reverts()
            .returns(someOtherValue)

So the first returns is called when the mock method is called for the 1st time, the reverts the second time and so on.

@rzadp rzadp added the waffle-mock-contract Anything related to the mocking package label Jul 29, 2022
@rzadp
Copy link
Contributor

rzadp commented Nov 10, 2022

Currently it is not implemented, but it's definitely a good feature to have.

@pawelpolak2
Copy link
Contributor

Implemented in #816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waffle-mock-contract Anything related to the mocking package
Projects
None yet
Development

No branches or pull requests

3 participants