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

Add support for destructured parameters in answers #512

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

Osguima3
Copy link
Contributor

@Osguima3 Osguima3 commented Feb 22, 2024

I think this is a useful addition as it takes benefit of a language feature instead of calling the (arguably) more verbose option of calling the getArgument<T>(i) method on the invocation:

on { intResult(any()) } doAnswer { (i: Int) -> i * 2 }

instead of (still supported):

on { intResult(any()) } doAnswer { it.getArgument<Int>(0) * 2 }

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! 1 small nit, the rest LGTM

@Osguima3 Osguima3 force-pushed the destructured-answers branch from 456c173 to ceedf0d Compare February 23, 2024 12:42
@Osguima3 Osguima3 requested a review from TimvdLippe February 23, 2024 18:14
@TimvdLippe TimvdLippe merged commit 44cada2 into mockito:main Feb 23, 2024
4 checks passed
@Osguima3 Osguima3 deleted the destructured-answers branch August 29, 2024 16:12
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

Successfully merging this pull request may close these issues.

2 participants