eclipse-vertx / vertx-junit5

Testing Vert.x applications with JUnit 5
Apache License 2.0
42 stars 30 forks source link

VertxExtention injection with reactivex modules fail in vertx 4.0.x #98

Closed vincentfree closed 3 years ago

vincentfree commented 3 years ago

I have upgraded a project that uses the reactivex modules heavily, while doing this I found that my tests break with the following message

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [io.vertx.reactivex.core.Vertx arg0] in method [public static final void com.ing.cerebro.api.endpoint.LovBaseTest.start elastic service(io.vertx.reactivex.core.Vertx,io.vertx.junit5.VertxTestContext)].

I've updated the import statements to the normal vertx modules and used the reactivex constructors/wrappers where I need to inject the rx versions of vertx and this works so it looks like injection with rxjava2 modules contains a bug.

I can't give a good reproducer because it's private company code. When I add the following: internal fun Vertx.toRx(): io.vertx.reactivex.core.Vertx = io.vertx.reactivex.core.Vertx(this) I can inject a io.vertx.core.Vertx instance wrap it and use it as usual so I can pinpoint the issue to the injection.

Questions

Do not use this issue tracker to ask questions, instead use one of these channels. Questions will likely be closed without notice.

Version

vertx 4.0.2 and 4.0.0

Steps to reproduce

  1. have a testcase in vertx 4.0.2
  2. use @ExtendWith(VertxExtension::class)
  3. use injection @Test fun testCase(vertx: io.vertx.reactivex.core.Vertx,testContext: VertxTestContext) { testContext.verify { Assertions.assertFalse(vertx.isClustered) } }

expectation: test can't be run due to ParameterResolutionException

Extra

JVM: openjdk 11 OS: MacOS

jponge commented 3 years ago

Did you add the Rx2 support module from https://github.com/vert-x3/vertx-rx/tree/master/rx-junit5-providers ?

vincentfree commented 3 years ago

Hi @jponge, I have just tied running with this module, now it can inject rxjava2 instances of Vertx! Thanks for this info.

I couldn't find it in the docs on the vertx.io website. I'd recon others might also run into this issue. Maybe this info can be added as a Rxified section of the Junit5 extensions docs?

I'm closing the issue.

jponge commented 3 years ago

It's documented in https://github.com/vert-x3/wiki/wiki/4.0.0-Deprecations-and-breaking-changes#vertx-junit5 :-)