https://kotlinlang.org logo
#kotest
Title
# kotest
j

Joel Hess

09/14/2021, 7:37 PM
Hello, Is there support for returning a value from the new eventually API’s? I’m looking at https://kotest.io/docs/framework/concurrency/eventually.html for details. I currently have something like this with kotest in 4.4:
Copy code
suspend fun RecommendationsExhaustedEventRepository.findByCausationIdEventually(causationId: UUID): RecommendationsExhaustedEvent {
    return eventually(30.seconds, IllegalStateException::class) {
        checkNotNull(
            this.findByCausationId(causationId)
        )
    }
}
and trying to do the same thing with 4.6. FWIW, I’m also fine with leaving the eventually as is, and not moving to the new API, but I get this too:
java.lang.NoSuchMethodError: 'java.lang.Object io.kotest.assertions.timing.EventuallyKt.eventually-8-LJAvk(double, kotlin.reflect.KClass, kotlin.jvm.functions.Function1, kotlin.coroutines.Continuation)'
I see that error with Kotlin 1.4.32 and 1.5.30
s

sam

09/14/2021, 8:02 PM
The old eventually has issues with the experimental duration support. That's why you see the errors and why we added new ones.
@Jim can you return a value from the new stuff ?
j

Jim

09/14/2021, 8:07 PM
I'm 90% sure, I'll check in a sec
io.kotest.framework.concurrency.eventually
does return a value:
Copy code
test("eventually returns the result computed inside") {
      val result = eventually(2.seconds()) {
         1
      }
      result shouldBe 1
   }
j

Joel Hess

09/15/2021, 1:44 AM
Thank you. Looks like that works. Might be a good doc update.
👍 1
👍🏻 1
13 Views