Skip to content

Instantly share code, notes, and snippets.

@jotak
Last active January 16, 2018 08:42
Show Gist options
  • Save jotak/3779cb4a8fc9a23cfdafd970cc386214 to your computer and use it in GitHub Desktop.
Save jotak/3779cb4a8fc9a23cfdafd970cc386214 to your computer and use it in GitHub Desktop.
TestContext and Async
@RunWith(VertxUnitRunner.class)
public class MyTest {
@Test
public void testRunningForever(TestContext context) {
Vertx vertx = Vertx.vertx();
Async async = context.async();
vertx.setTimer(1000, t -> {
context.fail("something wrong");
async.complete();
});
async.await();
}
@Test
public void testFailingAsExpected(TestContext context) {
Vertx vertx = Vertx.vertx();
Async async = context.async();
vertx.setTimer(1000, t -> {
try {
context.fail("something wrong");
} finally {
async.complete();
}
});
async.await();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment