Search in sources :

Example 1 with InvalidTestClassError

use of org.junit.runners.model.InvalidTestClassError 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));
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) ArrayList(java.util.ArrayList) Failure(org.junit.runner.notification.Failure) InvalidTestClassError(org.junit.runners.model.InvalidTestClassError) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Failure (org.junit.runner.notification.Failure)1 RunNotifier (org.junit.runner.notification.RunNotifier)1 InvalidTestClassError (org.junit.runners.model.InvalidTestClassError)1