use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class MaxStarterTest method rememberOldRuns.
@Test
public void rememberOldRuns() {
fMax.run(TwoUnEqualTests.class);
MaxCore reincarnation = MaxCore.storedLocally(fMaxFile);
List<Failure> failures = reincarnation.run(TwoUnEqualTests.class).getFailures();
assertEquals("fast", failures.get(0).getDescription().getMethodName());
assertEquals("slow", failures.get(1).getDescription().getMethodName());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class MaxStarterTest method correctErrorFromHalfMalformedTest.
@Test
public void correctErrorFromHalfMalformedTest() {
Request request = Request.aClass(HalfMalformedJUnit38TestMethod.class);
JUnitCore core = new JUnitCore();
Request sorted = fMax.sortRequest(request);
Runner runner = sorted.getRunner();
Result result = core.run(runner);
Failure failure = result.getFailures().get(0);
assertThat(failure.toString(), containsString("MalformedJUnit38TestMethod"));
assertThat(failure.toString(), containsString("testNothing"));
assertThat(failure.toString(), containsString("isn't public"));
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class PrintableResultTest method includeMultipleFailures.
@Theory
public void includeMultipleFailures(String secondExceptionName) {
PrintableResult backtrace = new PrintableResult(Arrays.asList(new Failure(Description.createSuiteDescription("firstName"), new RuntimeException("firstException")), new Failure(Description.createSuiteDescription("secondName"), new RuntimeException(secondExceptionName))));
assertThat(backtrace.toString(), containsString(secondExceptionName));
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class PrintableResultTest method backTraceHasGoodToString.
@Theory(nullsAccepted = false)
public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) {
Failure failure = new Failure(Description.createSuiteDescription(descriptionName), new Throwable() {
private static final long serialVersionUID = 1L;
@Override
public StackTraceElement[] getStackTrace() {
return new StackTraceElement[] { new StackTraceElement(stackTraceClassName, "methodName", "fileName", 1) };
}
});
assertThat(new PrintableResult(asList(failure)).toString(), allOf(containsString(descriptionName), containsString(stackTraceClassName)));
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class TimeoutRuleTest method nullTimeUnit.
@Test
public void nullTimeUnit() {
Result result = JUnitCore.runClasses(HasNullTimeUnit.class);
assertEquals(1, result.getFailureCount());
Failure failure = result.getFailures().get(0);
assertThat(failure.getException().getMessage(), containsString("Invalid parameters for Timeout"));
Throwable cause = failure.getException().getCause();
assertThat(cause.getMessage(), containsString("TimeUnit cannot be null"));
}
Aggregations