Awaitility 是多线程代码测试 DSL 框架,用于同步异步操作。
测试异步系统很难,它不仅需要处理线程,超时和并发问题,代码测试意图也需在此类细节下隐藏。但 Awaitility 可让您简明传达对异步系统的期望,且操作手册简单易懂,如:
@Testpublic 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()); ...}