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

Provide a short hand way to define every/everySuspend with all arg matchers set to any() #15

Open
dalewking opened this issue Jun 26, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dalewking
Copy link

dalewking commented Jun 26, 2024

In most of my use of Mocking I set up mocks without checking parameters of the call in the setup and instead check parameters in verification. It would be nice to have a way to define that without having to specify all the any() parameters. The way that could be done is with method references

So from the examples:

val repository = mock<BookRepository> {
   everySuspend { findById(any()) } calls { (id: String) -> Book(id) }
}

Would be able to be replaced by:

val repository = mock<BookRepository> {
   everySuspend(this::findById) calls { (id: String) -> Book(id) }
}
@lupuuss lupuuss added the enhancement New feature or request label Jun 26, 2024
@lupuuss
Copy link
Owner

lupuuss commented Jun 26, 2024

Good idea! It's not very straightforward to implement, but I will try it in the future.

@dalewking
Copy link
Author

Should figure out similar idea for verification, though will have to be different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants