Here you’ll find some examples of how to use Vert.x unit to test your asynchronous applications.
Tests are located in the link:src/test/java/io/vertx/example/unit/test directory.
Examples can be run directly from the IDE.
The link:src/test/java/io/vertx/example/unit/test/VertxUnitTest.java demonstrates how the Vert.x Unit API can be used to run tests using the Vert.x Unit test runner.
Run this example by running the main
method.
Vert.x Unit can be used with Junit:
-
link:src/test/java/io/vertx/example/unit/test/MyJunitTest.java demonstrates how to use the Vert.x Unit Junit runner to execute your tests
-
link:src/test/java/io/vertx/example/unit/test/ParameterizedTest.java demonstrates how to inject parameters into your Junit tests
-
link:src/test/java/io/vertx/example/unit/test/RunOnContextTest.java demonstrates how to delegate Vert.x instance creation to Vert.x Unit and how to use a rule to run the test methods on the event loop (caution: they must be non-blocking)
-
link:src/test/java/io/vertx/example/unit/test/JUnitAndAssertJTest.java demonstrates how to use AssertJ in combination with Vert.x Unit
-
link:src/test/java/io/vertx/example/unit/test/JUnitAndHamcrestTest.java demonstrates how to use Hamcrest in combination with Vert.x Unit
All the tests can be run from your IDE, or directly with Maven:
mvn clean test