/** * Interface TestListener for JUnit > 3.4. * * <p>A Test failed. * @param test the test. * @param t the assertion that failed. */ @Override public void addFailure(Test test, AssertionFailedError t) { addFailure(test, (Throwable) t); }
/** * Interface TestListener for JUnit <= 3.4. * * <p>A Test failed. * @param test the test. * @param t the exception. */ public void addFailure(Test test, Throwable t) { formatError("\tFAILED", test, t); }
@Override public void testAssumptionFailure(Test test, Throwable throwable) { formatSkip(test, throwable.getMessage()); }
public void formatSkip(Test test, String message) { if (test != null) { endTest(test); } try { wri.write("\tSKIPPED"); if (message != null) { wri.write(": "); wri.write(message); } wri.newLine(); } catch (IOException ex) { throw new BuildException(ex); } }
boolean success = false; try { write(String.format("Tests run: %d, Failures: %d, Errors: %d, Skipped: %d, Time elapsed: %s sec%n", suite.runCount(), suite.failureCount(), suite.errorCount(), suite.skipCount(), nf.format(suite.getRunTime() / ONE_SECOND))); write(String.format("------------- Standard Output ---------------%n")); write(systemOutput); write(String.format("------------- ---------------- ---------------%n")); write(String.format("------------- Standard Error -----------------%n")); write(systemError); write(String.format("------------- ---------------- ---------------%n")); write(System.lineSeparator()); if (out != null) { try { wri.flush(); write(inner.toString()); } catch (IOException ioex) { throw new BuildException("Unable to write output", ioex);
private void formatError(String type, Test test, Throwable t) { synchronized (wri) { if (test != null) { endTest(test); failed.put(test, Boolean.TRUE); } try { wri.write(type); wri.newLine(); wri.write(String.valueOf(t.getMessage())); wri.newLine(); String strace = JUnitTestRunner.getFilteredTrace(t); wri.write(strace); wri.newLine(); } catch (IOException ex) { throw new BuildException(ex); } } }
/** * Interface TestListener. * * <p>An error occurred while running the test. * @param test the test. * @param t the exception. */ @Override public void addError(Test test, Throwable t) { formatError("\tCaused an ERROR", test, t); }
@Override public void testIgnored(Test test) { formatSkip(test, JUnitVersionHelper.getIgnoreMessage(test)); }