Closed Broeckelmann closed 1 year ago
Have you tried to use onComplete
after sendJson
to understand if the
problem is with your web client call or vertx-junit5?
Yes I have, still times out sadly.
The assertion recieves the AsyncResult<HttpResponse
I have also tried closing the web-client manually after the assertion in case it is somehow blocking the testContext, but that does not changes anything.
Would you mind sharing a small reproducer?
I read up a bit on reproducers, sorry have never been asked that so far 😅.
I have changed the entire code snippets to a different verticle, but the problem remains the same. (to run it just build with gradle and then place the index.html file in src/main/resources/webroot/).
Found the problem, it's not a bug: you must complete the testContext
in the method annotated with @AfterEach
:
@AfterEach
fun `check that Verticle is still there`(vertx: Vertx, testContext: VertxTestContext) {
assertThat(vertx.deploymentIDs()).isNotEmpty.hasSize(1)
testContext.completeNow()
}
Or simply not inject it:
@AfterEach
fun `check that Verticle is still there`(vertx: Vertx) {
assertThat(vertx.deploymentIDs()).isNotEmpty.hasSize(1)
}
In both cases, the test passes.
Oh wow, that does make sense.
Thank you very much, good sir😄👍🏻.
Version
4.3.4
Context
I am using the vertx to run a web-server and now I want to test that said server. And I am using Kotlin instead of Java.
Problem Code
Test-code
index.html
build.gradle.kts
For some reason the testContext never gets completed and then the Test times out.
I used the testContext.assertComplete(...).onComplete(...) in all my other Vertx-Tests, but with the Web-Client it just does not work.
Any help would be appreciated 🙂.