Skip to content
Johan Haleby edited this page Nov 16, 2018 · 8 revisions

Awaitility has a Groovy API that allows you to write

await().until { numberOfReceivedMessages() > 3 }

All you have to do is to depend on the awaitility-groovy-3.1.0 module for this to work (if you're using Groovy 2.2 and above).

Prior to 2.0.0 (using Groovy 2.3 and above)

Implement the AwaitilityTrait that is provided in the awaitility-groovy module. Example:

class AwaitilityTraitTest implements AwaitilityTrait {

  @Test
  def void groovyClosureSupport()  {
    ... 

    await().until { numberOfReceivedMessages() > 3 }
  }
}

Groovy 2.2 and below

Extend or mixin the AwaitilitySupport class that is provided in the awaitility-groovy module. Example:

@Mixin(AwaitilitySupport)
class AwaitilitySupportTest {

  @Test
  def void groovyClosureSupport()  {
    ... 

    await().until { numberOfReceivedMessages() > 3 }
  }
}

Use the following Maven dependency

<dependency>
    <groupId>org.awaitility</groupId>
    <artifactId>awaitility-groovy</artifactId>
    <version>${awaitility.version}</version>
</dependency>

Example

  1. Groovy Trait Example
  2. Groovy Mixin Example