use of org.junit.runner.notification.Failure in project geode by apache.
the class RetryRuleGlobalWithErrorTest method failsOnSecondAttempt.
@Test
public void failsOnSecondAttempt() {
Result result = TestRunner.runTest(FailsOnSecondAttempt.class);
assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnSecondAttempt.message);
assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
use of org.junit.runner.notification.Failure in project geode by apache.
the class ExpectedTimeoutRuleTest method failsWithoutExpectedException.
@Test
public void failsWithoutExpectedException() {
Result result = TestRunner.runTest(FailsWithoutExpectedException.class);
assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage("Expected test to throw an instance of " + TimeoutException.class.getName());
}
use of org.junit.runner.notification.Failure in project geode by apache.
the class IgnoreUntilRuleTest method shouldExecuteWhenUntilIsDefault.
@Test
public void shouldExecuteWhenUntilIsDefault() {
Result result = TestRunner.runTest(ShouldExecuteWhenUntilIsDefault.class);
assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
assertThat(ShouldExecuteWhenUntilIsDefault.count).isEqualTo(1);
}
use of org.junit.runner.notification.Failure in project geode by apache.
the class RepeatRuleTest method failingTestShouldFailOneTimeWhenRepeatIsUnused.
@Test
public void failingTestShouldFailOneTimeWhenRepeatIsUnused() {
Result result = TestRunner.runTest(FailingTestShouldFailOneTimeWhenRepeatIsUnused.class);
assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
assertThat(FailingTestShouldFailOneTimeWhenRepeatIsUnused.count).isEqualTo(1);
}
use of org.junit.runner.notification.Failure in project jena by apache.
the class ModelTestSuite method runChild.
@Override
protected void runChild(Test child, RunNotifier notifier) {
Method setUp = null;
try {
setUp = child.getClass().getMethod("setUp");
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
throw new RuntimeException(e1);
} catch (NoSuchMethodException e1) {
}
Method tearDown = null;
try {
tearDown = child.getClass().getMethod("tearDown");
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
throw new RuntimeException(e1);
} catch (NoSuchMethodException e1) {
}
for (Method m : child.getClass().getMethods()) {
if (m.getName().startsWith("test") && m.getParameterTypes().length == 0) {
Description desc = Description.createTestDescription(child.getClass(), child.toString());
notifier.fireTestStarted(desc);
try {
if (setUp != null) {
setUp.invoke(child);
}
m.invoke(child);
if (tearDown != null) {
tearDown.invoke(child);
}
notifier.fireTestFinished(desc);
} catch (IllegalArgumentException e) {
notifier.fireTestFailure(new Failure(desc, e));
} catch (IllegalAccessException e) {
notifier.fireTestFailure(new Failure(desc, e));
} catch (InvocationTargetException e) {
notifier.fireTestFailure(new Failure(desc, e.getTargetException()));
} catch (RuntimeException e) {
notifier.fireTestFailure(new Failure(desc, e));
throw e;
}
}
}
}
Aggregations