use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInMethodRule.
@Test
public void getTrimmedStackForJUnit4TestFailingInMethodRule() {
Result result = runTest(TestWithThrowingMethodRule.class);
assertEquals("Should run the test", 1, result.getRunCount());
assertEquals("One test should fail", 1, result.getFailureCount());
Failure failure = result.getFailures().get(0);
assertHasTrimmedTrace(failure, message("java.lang.RuntimeException: cause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.doThrowExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.throwsExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$ThrowingMethodRule.apply"));
assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInTestRule.
@Test
public void getTrimmedStackForJUnit4TestFailingInTestRule() {
Result result = runTest(TestWithThrowingTestRule.class);
assertEquals("Should run the test", 1, result.getRunCount());
assertEquals("One test should fail", 1, result.getFailureCount());
Failure failure = result.getFailures().get(0);
assertHasTrimmedTrace(failure, message("java.lang.RuntimeException: cause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.doThrowExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.throwsExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$ThrowingTestRule.apply"));
assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInBeforeMethod.
@Test
public void getTrimmedStackForJUnit4TestFailingInBeforeMethod() {
Result result = runTest(TestWithThrowingBeforeMethod.class);
assertEquals("Should run the test", 1, result.getRunCount());
assertEquals("One test should fail", 1, result.getFailureCount());
Failure failure = result.getFailures().get(0);
assertHasTrimmedTrace(failure, message("java.lang.RuntimeException: cause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.doThrowExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.throwsExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$TestWithThrowingBeforeMethod.alwaysThrows"));
assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInTestMethod.
@Test
public void getTrimmedStackForJUnit4TestFailingInTestMethod() {
Result result = runTest(TestWithOneThrowingTestMethod.class);
assertEquals("Should run the test", 1, result.getRunCount());
assertEquals("One test should fail", 1, result.getFailureCount());
Failure failure = result.getFailures().get(0);
assertHasTrimmedTrace(failure, message("java.lang.RuntimeException: cause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.doThrowExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.throwsExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$TestWithOneThrowingTestMethod.alwaysThrows"));
assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class ErrorReportingRunnerTest method givenInvalidTestClassErrorAsCause.
@Test
public void givenInvalidTestClassErrorAsCause() {
final List<Failure> firedFailures = new ArrayList<Failure>();
InvalidTestClassError testClassError = new InvalidTestClassError(TestClassWithErrors.class, Arrays.asList(new Throwable("validation error 1"), new Throwable("validation error 2")));
ErrorReportingRunner sut = new ErrorReportingRunner(TestClassWithErrors.class, testClassError);
sut.run(new RunNotifier() {
@Override
public void fireTestFailure(Failure failure) {
super.fireTestFailure(failure);
firedFailures.add(failure);
}
});
assertThat(firedFailures.size(), is(1));
Throwable exception = firedFailures.get(0).getException();
assertThat(exception, instanceOf(InvalidTestClassError.class));
assertThat(((InvalidTestClassError) exception), is(testClassError));
}
Aggregations