Open freyliis opened 6 years ago
Hi
I have an issue similar to If an exception occurs, the test does not fail, but hangs #52. I added exceptionHandler with fail() but it still does not work, async hangs till timeout:
@RunWith(VertxUnitRunner.class) public class Test { protected final int PORT = 9988; @Rule public RunTestOnContext runTestOnContext = new RunTestOnContext(); @Before public void setupFakeServer(TestContext ctx) { runTestOnContext.vertx() .createHttpServer() .requestHandler(req -> req.response().end("unexpected")) .exceptionHandler(new Handler<Throwable>() { @Override public void handle(Throwable event) { System.err.println("Error"); ctx.fail(); } }) .listen(PORT, ctx.asyncAssertSuccess()); } @After public void tearDown(TestContext ctx) { runTestOnContext.vertx().close(ctx.asyncAssertSuccess()); } @org.junit.Test public void httpBodyHandler(TestContext ctx) { Async async = ctx.async(); runTestOnContext.vertx().createHttpClient().get(PORT, "localhost", "/", resp -> { ctx.assertEquals(200, resp.statusCode()); resp.bodyHandler(buff -> { buff.toJsonObject(); // fails and hangs here async.complete(); }); }).end(); } }
version of vertx-unit: 3.5.1
You're registering the exception handler on the HttpServer, not the Vertx instance/context which the tests are run on.
Hi
I have an issue similar to If an exception occurs, the test does not fail, but hangs #52. I added exceptionHandler with fail() but it still does not work, async hangs till timeout:
version of vertx-unit: 3.5.1