https://kotlinlang.org logo
#announcements
Title
# announcements
n

neverwintermoon

03/27/2017, 9:52 AM
Hello, I am in a bit of a tight spot trying to write a unit test. Is it possible to mock (with Mockito) a Kotlin extension function? I have extension functions for Uri, Uri itself is mocked, but mocking any of its functions seems to be calling an actual implementation....
k

kojdecki

03/27/2017, 10:08 AM
Top level extension functions are stored in a static class named after the file, eg.
Copy code
File: Extentions.Kt

fun Uri.test() {}
will create
ExtensionsKt.test(Uri smth)
- if I remember correctly 😉
n

neverwintermoon

03/27/2017, 10:15 AM
Aha, thanks
2 Views