I'm trying to use mockito_kotlin, but cannot figur...
# getting-started
d
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
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
e.g.
verify(myMock).myMethod(any())
verify that
myMethod
was called on
myMock
exactly once with any argument
p
use
mockk
instead.. Mockito was ok ten years ago, nowadays there are better options
#mockk
m
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’.
p
I’d take the plunge and dive right in to mockk. Having used Mockito and powermock for years I must say mockk is a joy to use. I found this article a great help when starting out: https://blog.philipphauer.de/best-practices-unit-testing-kotlin/