I’m running a kotest 4.2 on a Spring boot Integrat...
# kotest
j
I’m running a kotest 4.2 on a Spring boot Integration Test (with a
SpringBootTest
annotation) and using
eventually
to wait for a result, but it appears to not be waiting for the whole time.
Copy code
eventually(60.seconds) {
    val member = memberProjectionRepository.findByTenantIdAndClientMemberId(
       createMemberCmd.tenantId,
       clientMemberId
    )
    println("ack")
    member.shouldNotBeNull()
    member.clientMemberId.shouldBe(clientMemberId)
}
I see my
ack
in the output once or twice, but that’s it. any other tests that I have in the spec still continue to run as expected. How can I keep it from shutting down prematurely?
FWIW, this appears to work. I won’t argue with results, but I would expect my first attempt should have worked as well?
Copy code
val member = eventually(500.seconds, IllegalStateException::class) {
                checkNotNull(memberProjectionRepository.findByTenantIdAndClientMemberId(
                    createMemberCmd.tenantId,
                    clientMemberId
                ))
            }
            member.shouldNotBeNull()
            member.clientMemberId.shouldBe(clientMemberId)
s
It sounds like a bug if eventually is not waiting the full 60 seconds
Ah ok I see, it will by default only keep looping for `Exception`s
I wonder if you are throwing an
Error
instead
j
In the first snippet, the result is a nullable object, so no error is thrown aside from the assertion errors that would have occurred but the ShouldNotBeNull check.
Unless there’s something going on deeper in the system that I don’t know about.
j
Thanks for following up on this. I’ll update my stuff to reflect the pattern in the unit test!