I'm trying to use mockito_kotlin, but cannot figure out how to use the
any
(
inline fun <reified T : Any> any()
). What would be appropriate syntax here, to include a class T?
a
Alan Evans
01/07/2019, 4:54 PM
use it in
whenever
or
verify
calls as a placeholder for an argument that you don't want to specify, and no, not often do you need to specify T
Alan Evans
01/07/2019, 4:55 PM
e.g.
verify(myMock).myMethod(any())
Alan Evans
01/07/2019, 4:56 PM
verify that
myMethod
was called on
myMock
exactly once with any argument
p
poohbar
01/08/2019, 1:33 AM
use
mockk
instead.. Mockito was ok ten years ago, nowadays there are better options
poohbar
01/08/2019, 1:58 AM
#mockk
m
Mike
01/08/2019, 11:48 AM
There is nothing wrong with Mockito and Kotlin.
mockk is amazing, and handles a few Kotlin code items that Mockito doesn’t, but don’t switch just ‘because Mockito isn’t Kotlin native’.