import org.awaitility.Awaitility; import org.junit.Test; public class MyTest { @Test public void testAsynchronousOperation() { MyAsyncService asyncService = new MyAsyncService(); asyncService.start(); Awaitility.await().until(() -> asyncService.isFinished()); assertThat(asyncService.getResult()).isEqualTo(expectedResult); } } <dependency> <groupId>org.awaitility</groupId> <artifactId>awaitility</artifactId> <version>4.0.3</version> <scope>test</scope> </dependency>


上一篇:
下一篇:
切换中文