use of io.vertx.ext.unit.report.ReportOptions in project vertx-examples by vert-x3.
the class VertxUnitTest method run.
// Not yet detected
@CodeTranslate
public void run() {
TestOptions options = new TestOptions().addReporter(new ReportOptions().setTo("console"));
TestSuite suite = TestSuite.create("io.vertx.example.unit.test.VertxUnitTest");
suite.before(context -> {
vertx = Vertx.vertx();
vertx.createHttpServer().requestHandler(req -> req.response().end("foo")).listen(8080, context.asyncAssertSuccess());
});
suite.after(context -> {
vertx.close(context.asyncAssertSuccess());
});
// Specifying the test names seems ugly...
suite.test("some_test1", context -> {
// Send a request and get a response
HttpClient client = vertx.createHttpClient();
Async async = context.async();
client.getNow(8080, "localhost", "/", resp -> {
resp.bodyHandler(body -> context.assertEquals("foo", body.toString("UTF-8")));
client.close();
async.complete();
});
});
suite.test("some_test2", context -> {
// Deploy and undeploy a verticle
vertx.deployVerticle("io.vertx.example.unit.SomeVerticle", context.asyncAssertSuccess(deploymentID -> {
vertx.undeploy(deploymentID, context.asyncAssertSuccess());
}));
});
suite.run(options);
}
Aggregations