Last active
January 16, 2018 08:42
-
-
Save jotak/3779cb4a8fc9a23cfdafd970cc386214 to your computer and use it in GitHub Desktop.
TestContext and Async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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