/** * Create and returns a new async object, the returned async controls the completion of the test. * This async operation completes when the {@link io.vertx.rxjava.ext.unit.Async#countDown} is called <code>count</code> times.<p/> * If {@link io.vertx.rxjava.ext.unit.Async#countDown} is called more than <code>count</code> times, an {@link java.lang.IllegalStateException} is thrown.<p/> * * The test case will complete when all the async objects have their {@link io.vertx.rxjava.ext.unit.Async#complete} * method called at least once.<p/> * * This method shall be used for creating asynchronous exit points for the executed test.<p/> * @param count * @return the async instance */ public io.vertx.rxjava.ext.unit.Async strictAsync(int count) { io.vertx.rxjava.ext.unit.Async ret = io.vertx.rxjava.ext.unit.Async.newInstance(delegate.strictAsync(count)); return ret; }
/** * Create and returns a new async object, the returned async controls the completion of the test. * This async operation completes when the {@link io.vertx.rxjava.ext.unit.Async#countDown} is called <code>count</code> times.<p/> * If {@link io.vertx.rxjava.ext.unit.Async#countDown} is called more than <code>count</code> times, an {@link java.lang.IllegalStateException} is thrown.<p/> * * The test case will complete when all the async objects have their {@link io.vertx.rxjava.ext.unit.Async#complete} * method called at least once.<p/> * * This method shall be used for creating asynchronous exit points for the executed test.<p/> * @param count * @return the async instance */ public io.vertx.rxjava.ext.unit.Async strictAsync(int count) { io.vertx.rxjava.ext.unit.Async ret = io.vertx.rxjava.ext.unit.Async.newInstance(delegate.strictAsync(count)); return ret; }
@Test public void runTestWithStrictAsyncCountingDown() throws Exception { TestSuite suite = TestSuite.create("my_suite"). test("my_test", context -> { Async async = context.strictAsync(1); async.countDown(); async.countDown(); }); TestReporter reporter = new TestReporter(); run(suite, reporter); reporter.await(); assertTrue(reporter.completed()); assertEquals(0, reporter.exceptions.size()); assertEquals(1, reporter.results.size()); TestResult result = reporter.results.get(0); assertEquals("my_test", result.name()); assertTrue(result.failed()); assertTrue(result.failure().isError()); assertThat(result.failure().cause(), instanceOf(IllegalStateException.class)); }