From 575aee6e0471c4b012f2dec6789543cfc6c0cbe5 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 12 Apr 2025 04:03:46 +0200 Subject: [PATCH] test: fix flaky test --- .../eventDemo/libs/command/CommandStreamChannelTest.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/kotlin/eventDemo/libs/command/CommandStreamChannelTest.kt b/src/test/kotlin/eventDemo/libs/command/CommandStreamChannelTest.kt index 3afc896..1956e5f 100644 --- a/src/test/kotlin/eventDemo/libs/command/CommandStreamChannelTest.kt +++ b/src/test/kotlin/eventDemo/libs/command/CommandStreamChannelTest.kt @@ -1,5 +1,6 @@ package eventDemo.libs.command +import io.kotest.assertions.nondeterministic.eventually import io.kotest.core.spec.style.FunSpec import io.mockk.mockk import io.mockk.verify @@ -8,6 +9,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch import kotlinx.serialization.Serializable +import kotlin.time.Duration.Companion.seconds @Serializable class CommandTest( @@ -34,6 +36,9 @@ class CommandStreamChannelTest : } channel.send(command) - verify(exactly = 1) { spyCall() } + + eventually(3.seconds) { + verify(exactly = 1) { spyCall() } + } } })