In my project mostly all imports relay on io.vertx.reactivex.core.Vertx
package import, effectively makes whole project use reactivex
(not core
/vanilla) version of Vertx and it's verticles. I started to unit test a bit our application and to do so and to make it play nicely with JUint, according to this documentation following setup is needed to use JUnit and to run test cases in correct thread and verticle context:
@RunWith(VertxUnitRunner.class) /* Set the runner */
public class DaoTest {
@Rule /* Define rule to get vertx instance in test */
public RunTestOnContext rule = new RunTestOnContext();
@Test
public void exampleTest(TestContext context) {
TestClass t = new TestClass(rule.vertx());
}
}
the definition of TestClass
is following:
import io.vertx.reactivex.core.Vertx; /* Mind here */
public class TestClass {
public TestClass(Vertx vertx) {
/* Something */
}
I'm unable to provide correct instance of Vertx
because only one definition of RunTestOnContext
exist in package io.vertx.ext.unit.junit
and produces io.vertx.core.Vertx
instance, which is incompatible with io.vertx.reactivex.core.Vertx
that TestClass
is using. Some other test utilities, like TestContext have their equivalents in reactivex
packages io.vertx.reactivex.ext.unit.TestContext
, but this seems not be a case for RunTestOnContext
.
The question would be how to obtain correctly io.vertx.reactivex.core.Vertx
instance in test context to still ensure thread and context consistency?
Aucun commentaire:
Enregistrer un commentaire