Closed matthewadams closed 6 years ago
Hi @matthewadams, VertxTestContext
does not throw any exception.
You can check that the context is properly failed using context.failed()
and context.causeOfFailure()
. So what you should be doing is inspecting the context, and then making the test fail by throwing the exception.
Since you use the extension, you can benefit from parameter injection and test context management:
@Test
public void testGetNewToken(Vertx vertx, VertxTestContext context) {
AuthenticatorStub auth = new AuthenticatorStub(vertx);
auth.getToken().subscribe(token -> {
try {
fail("bogus");
context.completeNow();
} catch (Throwable t) {
context.failNow(t);
}
}, context::failNow);
}
This fails properly, just as you would expect.
Nvm. Just saw your code. I’m glad it was StupidUserException!
On Fri, May 25, 2018 at 3:30 PM Julien Ponge notifications@github.com wrote:
Hi @matthewadams https://github.com/matthewadams, VertxTestContext does not throw an exception.
You can check that the context is properly failed using context.failed() and context.causeOfFailure(). So what you should be doing is inspecting the context, and then making the test fail by throwing the exception.
Since you use the extension, you can benefit from parameter injection and test context management:
@Test public void testGetNewToken(Vertx vertx, VertxTestContext context) throws InterruptedException { AuthenticatorStub auth = new AuthenticatorStub(vertx); auth.getToken().subscribe(token -> { try { fail("bogus"); context.completeNow(); } catch (Throwable t) { context.failNow(t); } }, context::failNow); }
This fails properly, just as you would expect.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vert-x3/vertx-junit5/issues/40#issuecomment-392173765, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbdoBcM6U3xLAaMd3rjAE9c4Zem9Hxzks5t2Gn-gaJpZM4UOW19 .
FYI, filed related issue: https://github.com/vert-x3/vertx-junit5/issues/41
Using
Reproducible test case:
If I run this test, it succeeds, when it should fail: