mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.11k stars 202 forks source link

Add support for destructured parameters in answers #512

Closed Osguima3 closed 7 months ago

Osguima3 commented 7 months ago

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 }