"f:can sync" {
val clock = mockk<Clock>()
every { clock.instant() } returns YESTERDAY andThen NOW
}
"f:can delete" {
val clock = mockk<Clock>()
every { clock.instant() } returns YESTERDAY andThen NOW andThen NOW
}
the first one logs:
Copy code
10:33:28.099 [kotest-engine-0 @coroutine#2] DEBUG io.mockk.impl.instantiation.AbstractMockFactory - Creating mockk for Clock name=#1
10:33:29.228 [kotest-engine-0 @coroutine#2] DEBUG io.mockk.impl.instantiation.AbstractMockFactory - Creating mockk for Instant name=child of #1#2
the second one
Copy code
10:33:29.245 [kotest-engine-0 @coroutine#3] DEBUG io.mockk.impl.instantiation.AbstractMockFactory - Creating mockk for Clock name=#3
10:33:29.247 [kotest-engine-0 @coroutine#3] DEBUG io.mockk.impl.instantiation.AbstractMockFactory - Creating mockk for Instant name=child of #3#4
how comes in the first test it takes one second to create a mock?
thanksforallthefish
06/23/2020, 8:36 AM
Clock
is a
java.time.Clock
l
LeoColman
06/23/2020, 3:04 PM
Probably due to reflection initialization
LeoColman
06/23/2020, 3:04 PM
The first time you use reflection it takes a lot of time
LeoColman
06/23/2020, 3:05 PM
Try to invert both tests and see if it changes
t
thanksforallthefish
06/28/2020, 4:47 AM
@LeoColman Sorry, I missed your reply somehow. that is the first thing I tried and indeed inverting the order inverts the slowness. what strucks me as weird is that unit test are supposed to be fast, if it takes >1s for reflection initialization we are the realm of slow tests. weirdly enough I did not realize this problem with other interfaces, clock seems to be the one