io.vertx.ext.unit.junit.VertxUnitRunner Java Examples

The following examples show how to use io.vertx.ext.unit.junit.VertxUnitRunner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JUnitTest.java    From vertx-unit with Apache License 2.0 5 votes vote down vote up
private Result run(Class<?> testClass) {
  try {
    return new JUnitCore().run(new VertxUnitRunner(testClass));
  } catch (InitializationError initializationError) {
    throw new AssertionError(initializationError);
  }
}
 
Example #2
Source File: JUnitTest.java    From vertx-unit with Apache License 2.0 5 votes vote down vote up
@Test
public void testMethodRule() throws Exception {
  Result result = new JUnitCore().run(new VertxUnitRunner(MethodRuleTestSuite.class));
  assertEquals(0, result.getFailures().size());
  assertEquals(1, MethodRuleTestSuite.count.get());
  assertEquals(0, MethodRuleTestSuite.rule.failures.size());
  assertEquals(1, MethodRuleTestSuite.rule.methods.size());
  assertEquals(MethodRuleTestSuite.class.getDeclaredMethod("testMethod", TestContext.class), MethodRuleTestSuite.rule.methods.get(0).getMethod());
  assertEquals(1, MethodRuleTestSuite.rule.targets.size());
  assertTrue(MethodRuleTestSuite.rule.targets.get(0) instanceof MethodRuleTestSuite);
  assertEquals(1, MethodRuleTestSuite.rule.evaluateCount.get());
}
 
Example #3
Source File: JUnitTest.java    From vertx-unit with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingMethodRule() throws Exception {
  Result result = new JUnitCore().run(new VertxUnitRunner(FailingMethodRuleTestSuite.class));
  assertEquals(1, FailingMethodRuleTestSuite.rule.failures.size());
  assertEquals(1, result.getFailures().size());
  Failure failure = result.getFailures().get(0);
  assertSame(failure.getException(), FailingMethodRuleTestSuite.rule.failures.get(0));
  assertEquals(1, FailingMethodRuleTestSuite.rule.methods.size());
  assertEquals(FailingMethodRuleTestSuite.class.getDeclaredMethod("testMethod", TestContext.class), FailingMethodRuleTestSuite.rule.methods.get(0).getMethod());
  assertEquals(1, FailingMethodRuleTestSuite.rule.targets.size());
  assertTrue(FailingMethodRuleTestSuite.rule.targets.get(0) instanceof FailingMethodRuleTestSuite);
  assertEquals(1, FailingMethodRuleTestSuite.rule.evaluateCount.get());
}