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"));
}
use of org.junit.runner.notification.Failure in project pinpoint by naver.
the class PinpointPluginTestStatement method toFailure.
private Failure toFailure(Description parentDescription, String displayName, String exceptionClass, String message, List<String> trace) {
Description desc = findDescription(parentDescription, displayName);
Exception exception = toException(message, exceptionClass, trace);
Failure failure = new Failure(desc, exception);
return failure;
}
Aggregations