You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer the following questions for yourself before submitting an issue.
I am running the latest version
I checked the documentation and found no answer
I checked to make sure that this issue has not already been filed
Expected Behavior
I would expect verify(timeout) to continue to work like it did before 1.13.7, so that CapturingSlots can capture values added from coroutines. Previously our tests worked as expected.
Current Behavior
Verify (timeout) does not seem to be waiting for the timeout, so tests are becoming flaky because of race conditions in the test code. About a third of the time the test will fail because the CapturingSlot has not yet captured the value we are checking for.
If we add a thread.sleep(250) before the call to verify, the test will not fail.
The problem started in version 1.13.7 and is still present in version 1.13.8.
Failure Information (for bugs)
This might be related to the change in #1099, like is mentioned in #1133 ? If the mock is cleared before the timeout check is done, or possibly during the timeout wait loop, the timeout could be instant.
Below is a minimal reproduction of the conditions that cause the issue.
// -----------------------[ YOUR STACK STARTS HERE ] -----------------------
kotlin.UninitializedPropertyAccessException: lateinit property captured has not been initialized
at io.mockk.CapturingSlot.getCaptured(API.kt:2626)
// -----------------------[ YOUR STACK TRACE ENDS HERE ] -----------------------
privateval logbackLogger:OurLogger= mockk()
privatelateinitvar logStringSlot:CapturingSlot<String>
@BeforeEach
funsetUp() {
logStringSlot = slot<String>()
every { logbackLogger.log(capture(logStringSlot)) } returns UnitReflectionTestUtils.setField(backingService, "logbackLogger", logbackLogger)
}
@Test
fun`Log request`() {
val request = createRequest()
trackingService.trackRequest(request)
//Adding a thread.sleep(250) here will work around the issue
verify(timeout =5000) { logbackLogger.log(any()) }
//Fails around 1/3 of the time with kotlin.UninitializedPropertyAccessException: lateinit property captured has not been initializedval captured = logStringSlot.captured
assertThat(captured)
.and("info")
.areIdentical()
}
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Expected Behavior
I would expect verify(timeout) to continue to work like it did before 1.13.7, so that CapturingSlots can capture values added from coroutines. Previously our tests worked as expected.
Current Behavior
Verify (timeout) does not seem to be waiting for the timeout, so tests are becoming flaky because of race conditions in the test code. About a third of the time the test will fail because the CapturingSlot has not yet captured the value we are checking for.
If we add a thread.sleep(250) before the call to verify, the test will not fail.
The problem started in version 1.13.7 and is still present in version 1.13.8.
Failure Information (for bugs)
This might be related to the change in #1099, like is mentioned in #1133 ? If the mock is cleared before the timeout check is done, or possibly during the timeout wait loop, the timeout could be instant.
Below is a minimal reproduction of the conditions that cause the issue.
The text was updated successfully, but these errors were encountered: