Justin (Midas) Gilman
09/27/2021, 7:55 PMjava.lang.AbstractMethodError: Receiver class kotlin.jvm.functions.Function1$Subclass0 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object invoke(java.lang.Object)' of interface kotlin.jvm.functions.Function1.
Here's my test:
@Test
fun `attempt 2`() {
val routing = mockk<Routing>(relaxed = true)
val configure = slot<Route.() -> Unit>()
val mockedRoute = mockk<Route>()
every { any<Route>().static(capture(configure)) } answers {
configure.captured.invoke(mockedRoute)
mockedRoute
}
var testObj = ResourcePortalModuleRouter(routing, node)
testObj.attachPortalCoreRoutes()
verify {
mockedRoute.default("index")
}
}
The error is thrown on the every
line, and I don't understand why this isn't workingTobias Berger
09/27/2021, 9:30 PMmockkstatic("<file class qualified name>")
, so if you have a file called MyExtensions.kt
in package com.example.myapp
you would write mockkstatic("com.example.myapp.MyExtensionsKt")
.
I'm not 100% sure about mocking extensions in combination with the any-matcher, but that shouldn't make a difference when I think about it.ephemient
09/28/2021, 2:34 AMmockkStatic(Routing::static)
instead of relying on the class nameephemient
09/28/2021, 2:40 AMJustin Gilman
09/28/2021, 3:29 PM