it seems that <a recommended way to mock extension...
# mockk
d
it seems that a recommended way to mock extensions with Mockk is to define a 
@file:JvmName
 and refer to it with 
mockkStatic("<jvm-name>")
, which is not type safe: In case of refactoring (e.g. rename or package change), the tests might break inadvertently. Is there a more type safe manner to mock extension functions?
m
yes, it’s a relatively recent addition: https://mockk.io/#extension-functions
you can use either
Copy code
mockkStatic(Obj::extensionFunc)
or
Copy code
@file:JvmName("KHttp")
which has indeed the problem that it is not safe towards class renaming, you’re right
👍 1
d
ah, I like the alternative using the method reference. It is potentially more code to write (for several extensions), but also more robust
thanks!
👍 1
j
just ran into this, good alternative