Johan Haleby edited this page Jul 24, 2018 · 5 revisions

Awaitility has a support module called awaitility-kotlin that contains a file called AwaitilityKt (in package org.awaitility.kotlin which contains some useful extension functions.


Import this extension function (import org.awaitility.kotlin.untilCallTo) and then you can write tests like this:

val myRepository : MyRepository = ...

// Wait until call to myRepository.count() is equal to 3
await().untilCallTo { myRepository.count() } matches { count -> count == 3 }

Other Examples

As of version 3.1.2 you can also do for example:

await withPollInterval ONE_HUNDRED_MILLISECONDS ignoreException IllegalArgumentException::class untilAsserted  {


await withAlias "Kotlin Test" ignoreExceptionsInstanceOf
      IllegalArgumentException::class withPollDelay ONE_HUNDRED_MILLISECONDS withPollInterval
      fibonacci().with().offset(1).and().timeUnit(MILLISECONDS) atLeast TWO_HUNDRED_MILLISECONDS atMost
      ONE_MINUTE untilCallTo { fakeRepository.value } matches { it == 1 }

Use the following Maven dependency:



You can’t perform that action at this time.
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.
Press h to open a hovercard with more details.