Mockk "verify" takes up to 6 seconds when verifying method with 3 or more parameters

437 Views Asked by At

I use mockk (versions 1.12.0 and 1.12.3) in @SpringBootTest in order to create a spy of some service and verify later that the service's method was (or was not) called. This looks like this:

@SpringBootTest
class MyTests {
    @Autowired
    private lateinit var someBean: SomeBean

    @TestConfiguration
    class Config {
        @Bean
        @Primary
        fun someBeanSpy(someBean: SomeBean) = spyk(someBean)
    }

    @BeforeEach
    internal fun setUp() {
        clearAllMocks()
    }

    @ParameterizedTest
    @MethodSource("data")
    fun `some test`(s: String) {
        // prepare data and call controller
        verify(exactly = 0) { someBean.foo(any(), any(), any()) } // <- execution of this verify lasts about 6 seconds
        // other verify statements last about 200ms
    }

    companion object {
        @JvmStatic
        fun data(): Stream<Arguments> = Stream.of(Arguments.of("abc"), Arguments.of("cde"))
    }
}

However, the execution of verify method on spy's methods with 3 or more parameters take too long time. Why may I have such behavior?

The same works fine with Mockito, but I don't want to use it with Kotlin because than I can't use just regular Mockito#any with non-nullable types.

Also, when I reduced the SomeBean#foo method's number of parameters from 3 to 2, verify executed just as normal, about 200ms.

0

There are 0 best solutions below