Szymon Jeziorski
11/25/2022, 12:49 PM@SpykBean
, but cannot get it working.
my setup looks roughly like this:
@SpringBootTest
class SomeTestClass(
[...]
) : FunSpec() {
@SpykBean
private lateinit var someService: SomeService
init {
test("some test") {
[...]
verify { someService.someMethod(someArg) } // ERROR here
}
}
}
Test breaks when hitting verify
block with beginning of the stack trace looking as follows:
java.lang.NoClassDefFoundError: io/mockk/ValueClassSupportKt
at io.mockk.impl.instantiation.JvmMockFactoryHelper.toDescription$mockk(JvmMockFactoryHelper.kt:150)
at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation(JvmMockFactoryHelper.kt:25)
at io.mockk.proxy.jvm.advice.Interceptor.call(Interceptor.kt:21)
I tried using MockKAnnotations.init()
, @ExtendWith(MockKExtension::class)
, moving @SpykBean
to companion object, but nothing helped.
Have anyone had such issue or could think of a solution?
Thanks in advanceEmil Kantis
11/25/2022, 1:12 PMsomeArg
a value class? IIRC there's issues with value classes in MockK still. The problem sounds unrelated to kotestSzymon Jeziorski
11/25/2022, 1:52 PMsomeArg
is Java class coming from generated resources in my case, but looks like the issue is with spy object itself, not with passed arguments. Verifying no-args method call results in same issue.
Example with simple Spring's bean:
@RestController
class SomeController {
@GetMapping("/test")
fun something() = "something"
}
@SpringBootTest
class SomeTestClass(
[...]
) : FunSpec() {
@SpykBean
private lateinit var someController: SomeController
init {
test("some test") {
[...]
verify { someController.something() } // ERROR here
}
}
}
Taking a look at the spy property within test class and intercepted MockK call within debug looks as attached.
Looks like issue on the MockK site, but this wasn't a case with JUnit, so not sure what I'm missing.
(Hidden base package names in screenshots)Szymon Jeziorski
11/25/2022, 1:53 PMSzymon Jeziorski
11/25/2022, 1:55 PMSzymon Jeziorski
11/25/2022, 3:00 PM