https://kotlinlang.org logo
Title
g

ghedeon

06/10/2018, 5:41 PM
just to understand it clear, when it says "static mocks in mockk" it actually refers to extension functions? Or, is it also possible to mock something like
Html.fromHtml()
?
o

oleksiyp

06/10/2018, 9:16 PM
So basically static mockk just allow to mock java static methods. Top level extension functions are implemented as static methods in Java byte code, so that's why it's needed. Other types of extension functions require different mocking approach. Making automagical detection what type of extension function you have I doubt is possible, so you need to understand this pieces of implementation details
g

ghedeon

06/10/2018, 10:10 PM
mockk just allow to mock java static methods
android.text.Html.fromHtml()
is a java class in android SDK. To be able to mock it, I wrapped it into a kotlin extension function and mocked that function with mockkStatic. Works perfectly, thanks for that! Just to clarify, the question remains, is it possible to mock the
#fromHtml()
directly, assuming it's not an extension and comes from java?
o

oleksiyp

06/11/2018, 4:17 AM
Just try, depends many things