How do you Mockk a Kotlin top level function?
There is way to mockk a top level function:
mockkStatic("pkg.FileKt")
every { fun() } returns 5
You just need to know which file this function goes. Check in JAR or stack trace.
The following syntax has worked to me.
mockkStatic(::sayHello.javaMethod!!.declaringClass.kotlin)
I'm surprised there is nothing on the jvm-stdlib
yet for this.
Edit: This overload has now been introduced officially: https://github.com/mockk/mockk/pull/518
mockkStatic(::sayHello)