use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class ExpectedTest method unexpected.
@Test
public void unexpected() {
Result result = JUnitCore.runClasses(Unexpected.class);
Failure failure = result.getFailures().get(0);
String message = failure.getMessage();
assertTrue(message.contains("expected<java.lang.Exception> but was<java.lang.Error>"));
assertEquals(Error.class, failure.getException().getCause().getClass());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class FailedConstructionTest method failedConstructionIsTestFailure.
@Test
public void failedConstructionIsTestFailure() {
Result result = JUnitCore.runClasses(CantConstruct.class);
Failure failure = result.getFailures().get(0);
Description expected = Description.createTestDescription(CantConstruct.class, "foo");
Assert.assertEquals(expected, failure.getDescription());
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class TextListener method printFailures.
protected void printFailures(Result result) {
List<Failure> failures = result.getFailures();
if (failures.isEmpty()) {
return;
}
if (failures.size() == 1) {
getWriter().println("There was " + failures.size() + " failure:");
} else {
getWriter().println("There were " + failures.size() + " failures:");
}
int i = 1;
for (Failure each : failures) {
printFailure(each, "" + i++);
}
}
use of org.junit.runner.notification.Failure in project junit4 by junit-team.
the class JUnit4ClassRunner method testAborted.
private void testAborted(RunNotifier notifier, Description description, Throwable e) {
notifier.fireTestStarted(description);
notifier.fireTestFailure(new Failure(description, e));
notifier.fireTestFinished(description);
}
use of org.junit.runner.notification.Failure in project mockito by mockito.
the class UnnecessaryStubbingsReporter method validateUnusedStubs.
public void validateUnusedStubs(Class<?> testClass, RunNotifier notifier) {
Collection<Invocation> unused = new UnusedStubbingsFinder().getUnusedStubbingsByLocation(mocks);
if (unused.size() == 0) {
//whoa!!! All stubbings were used!
return;
}
//Oups, there are unused stubbings
Description unnecessaryStubbings = Description.createTestDescription(testClass, "unnecessary Mockito stubbings");
notifier.fireTestFailure(new Failure(unnecessaryStubbings, Reporter.formatUnncessaryStubbingException(testClass, unused)));
}
Aggregations