use of io.vertx.ext.unit.TestSuite in project sonar-java by SonarSource.
the class A method test_saveUser.
@Test
public void test_saveUser() {
// Compliant even if this test may not be run correctly - assertion is present
TestSuite suite = TestSuite.create("suite_user_save");
HttpClient client = vertx.createHttpClient();
suite.test("user_save", context -> {
client.getNow(port, host, requestURI, resp -> {
resp.bodyHandler(body -> {
// assertion
context.assertNotEquals("created", body.toString());
client.close();
});
});
});
}
use of io.vertx.ext.unit.TestSuite 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