Vert.x - Timed out Exception when testing

Java Conceptuel Diagram


This is a really common error when you start with Vert.x and I lost a couple of hours on that many times. I figure out, I will put it available to everybody.


If you get an error like that when you are making a test.

Timed out
java.util.concurrent.TimeoutException: Timed out
	at io.vertx.ext.unit.impl.CompletionImpl.awaitSuccess(
	at net.bytle.api.db.DatabaseVerticleTest.getIt(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at io.vertx.ext.unit.junit.VertxUnitRunner.invokeTestMethod(
	at io.vertx.ext.unit.junit.VertxUnitRunner.lambda$invokeExplosively$0(
	at io.vertx.ext.unit.junit.VertxUnitRunner.invokeExplosively(
	at io.vertx.ext.unit.junit.VertxUnitRunner.access$000(
	at io.vertx.ext.unit.junit.VertxUnitRunner$1.evaluate(
	at io.vertx.ext.unit.junit.VertxUnitRunner$2.evaluate(


There is a lot of chance that's because, you didn't complete your async. ie you forgot the async.complete(); line.


public void getIt(TestContext context) {

	Async async = context.async();
	service.getIt(context.asyncAssertSuccess(body -> {
	  context.assertEquals(0, body.fieldNames().size(), "No key");
	  async.complete(); // Without this line, you will got a timed out exception


Share this page:
Follow us:
Task Runner