Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

any(Class.class) equivalent in kotlin mockito

In java we would do the following:

verify(myTestObject).execute(any(Callback.class))

In kotlin if I use any(Callback::class) I get "too many arguments for public fun any(): T defined in com.nhaarman.mockitokotlin2".

like image 588
Илья Avatar asked Jan 25 '26 15:01

Илья


1 Answers

You have to specify the class as generic type argument:

verify(myTestObject).execute(any<Callback>())

Or, due to type inference, you can leave it out:

verify(myTestObject).execute(any())
like image 152
Rene Avatar answered Jan 27 '26 05:01

Rene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!