Closed aygalinc closed 5 years ago
@aygalinc you're headed in the right direction. The problem in your test is that Assertions#fail
does not report the failure to the TestContext
. As a consequence, the test continues to run until it timeouts.
You should wrap the assertj assertions with TestContext#verify
. Like this:
vertx.rxUndeploy("test")
.subscribe(() -> context.verify(v -> {
fail("always fail");
}), throwable -> context.verify(v -> {
fail("always fail");
}));
See http://vertx.io/docs/vertx-unit/java/#_using_third_party_assertion_framework
thank you !
But now in log I have all the stack trace of an UndeliverableException. Do you recommend to do before launching test : RxJavaPlugins.setErrorHandler(t -> {}); Or leave the UndeliverableException stack trace which can be confusing when someone read test log ?
I would just focus on the error reported by junit but that's just me :)
Hi,
It is not clear in documentation how to test wth Vertx-Unit the Rxified vertx (I tried Rxified 2 version).
Async & test context have their pendant in Rx, but not VertxRunner or RunOnContext rule.
I use Rx2 vertx in some test & it always wait the timeout to fail, even if some assertion fail before. But they are not propagated to vertx context.
A quick reproducer is : ` import static org.assertj.core.api.Assertions.fail;
import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.RunTestOnContext; import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.reactivex.core.Vertx; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith;
@RunWith(VertxUnitRunner.class) public class DummyTest {
@Rule public RunTestOnContext rule = new RunTestOnContext();
private Vertx vertx;
@Before public void setUp(TestContext context) { vertx = new io.vertx.reactivex.core.Vertx(rule.vertx()); vertx.exceptionHandler(context.exceptionHandler()); }
@Test(timeout = 1000L) public void dummyTest(TestContext context){ Async async = context.async();
} } `
And I have to wait the timeout as shown in log :
java.util.concurrent.TimeoutException at io.vertx.ext.unit.impl.TestContextImpl.lambda$run$1(TestContextImpl.java:79) at java.lang.Thread.run(Thread.java:748)