https://kotlinlang.org logo
#mockk
Title
# mockk
d

dave08

06/10/2018, 5:37 PM
How do I mock
resolve
extension from Kotlin stdlib on a File? I tried this, but it still seems to call the Kotlin code:
Copy code
fun mockFile() = mockk<File>().apply {
	every { resolve(any<File>()) } answers { mockk<File>(relaxed = true).apply {
		every { path } returns "this.txt"
	} }
}

// Gives
path must not be null
java.lang.IllegalStateException: path must not be null
	at kotlin.io.FilesKt__FilePathComponentsKt.isRooted(FilePathComponents.kt:81)
	at kotlin.io.FilesKt__UtilsKt.resolve(Utils.kt:400)
g

ghedeon

06/10/2018, 5:38 PM
8 Views