awaitility / awaitility

Awaitility is a small Java DSL for synchronizing asynchronous operations
Apache License 2.0
3.83k stars 244 forks source link

Support for `kotlin.time.Duration` in Kotlin DSL #235

Open vladimirfx opened 2 years ago

vladimirfx commented 2 years ago

Usage:

await atMost 5.seconds untilAsserted { }

Impl:

import kotlin.time.Duration
import kotlin.time.toJavaDuration

infix fun ConditionFactory.atMost(duration: Duration): ConditionFactory = atMost(duration.toJavaDuration())

infix fun ConditionFactory.atLeast(timeout: Duration): ConditionFactory = atLeast(timeout.toJavaDuration())

infix fun ConditionFactory.withPollDelay(pollDelay: Duration): ConditionFactory = pollDelay(pollDelay.toJavaDuration())

infix fun ConditionFactory.withPollInterval(pollInterval: Duration): ConditionFactory =
    pollInterval(pollInterval.toJavaDuration())

infix fun ConditionFactory.during(duration: Duration): ConditionFactory = during(duration.toJavaDuration())
vladimirfx commented 2 years ago

I can provide the PR

jantobola commented 2 years ago

I was surprised that there is no support for Kotlin Duration in the awaitility-kotlin module. It makes sense to have it. This issue is pretty old and yet there are no responses. @johanhaleby Are you open to including this in a future release since it's a very simple and straightforward change?

piefel commented 4 months ago

This would be quie convenient. It also easy to include!

In the meantime, I added the above lines to my project locally.