/** * Set a callback executed before the tests. * @param callback the callback * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestSuite before(Handler<io.vertx.rxjava.ext.unit.TestContext> callback) { delegate.before(new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { callback.handle(io.vertx.rxjava.ext.unit.TestContext.newInstance(event)); } }); return this; }
}); if (i == 0) { suite = suite.before(context -> { count.compareAndSet(0, 1); queue.add(context.async());
}); } else { suite = suite.before(context -> { count.incrementAndGet(); });
/** * Set a callback executed before the tests. * @param callback the callback * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestSuite before(Handler<io.vertx.rxjava.ext.unit.TestContext> callback) { delegate.before(new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { callback.handle(io.vertx.rxjava.ext.unit.TestContext.newInstance(event)); } }); return this; }
test("my_test_2", context -> count.incrementAndGet()); if (i == 0) { suite.before(context -> { throw new RuntimeException(); });
test(testCaseName1, context -> { }). before(context -> { context.fail("the_before_failure"); });
List<Integer> afterEach = Collections.synchronizedList(new ArrayList<>()); List<Integer> after = Collections.synchronizedList(new ArrayList<>()); TestSuite suite = TestSuite.create("my_suite").before(context -> { Integer value = context.get("value"); if (value != null) {
@org.junit.Test public void testReportToFailureCompletionHandler() { RuntimeException e = new RuntimeException(); Handler<TestContext> fails = context -> { throw e; }; Handler<TestContext> pass = context -> { }; TestSuite[] suites = { TestSuite.create("my_suite").test("first_test", fails), TestSuite.create("my_suite").before(fails).test("first_test", pass), TestSuite.create("my_suite").test("first_test", pass).after(fails) }; AtomicInteger count = new AtomicInteger(); for (TestSuite suite : suites) { suite.run(new TestOptions()).handler(ar -> { assertTrue(ar.failed()); assertSame(e, ar.cause()); if (count.incrementAndGet() == 3) { testComplete(); } }); } await(); } }