Testing asynchronous systems is hard. Not only does it require handling threads, timeouts and concurrency issues, but the intent of the test code can be obscured by all these details. Awaitility is a DSL that allows you to express expectations of an asynchronous system in a concise and easy to read manner. For example:
@Test
public void updatesCustomerStatus() throws Exception {
// Publish an asynchronous event:
publishEvent(updateCustomerStatusEvent);
// Awaitility lets you wait until the asynchronous operation completes:
await().atMost(5, SECONDS).until(customerStatusIsUpdated());
...
}
- 2016-06-17: Awaitility 2.0.0 is released with support for at least expressions as well as upgraded Groovy and Scala support. See release notes for more details.
- 2016-06-17: Awaitility has a new website, http://www.awaitility.org. Feel free to update your bookmarks.
- 2015-11-27: Awaitility 1.7.0 is released with support for non-fixed poll intervals. By default Awaitility ships with fibonacci, iterative and ability to roll your own. To simplify custom poll intervals Duration has been updated with methods such as
plus
,minus
,multiply
anddivide
. A new helper method called matches has also been added to Awaitility to reduce boiler plate code when creating lambda expressions that call methods that throws exception. See change log for details and see this blog for additional info.
- Change log
- Awaitility on Ohloh
- Mailing list for questions and support