With JUnit, the required Maven dependencies are the following:
JUnit tests need to be annotated with the VertxUnitRunner
runner to use the vertx-unit
features:
With that runner, JUnit test and life-cycle methods accept a argument. This object provides access to basic assertions, a context to store data, and several async-oriented helpers that we will see in this section.
TestContext
is a parameter provided by the runner.Since we are in unit tests, we need to create a Vert.x context.
This
Async
object works as a countdown that completes successfully after 3 calls.Each periodic task tick triggers a countdown. The test passes when all
Async
objects have completed.