/** The whole testsuite ended. */ public void endTestSuite(JUnitTest suite) throws BuildException { rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); rootElement.setAttribute(ATTR_TIME, "" + (suite.getRunTime() / 1000.0)); if (out != null) { Writer wri = null; try { wri = new BufferedWriter(new OutputStreamWriter(out, "UTF8")); wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); (new DOMElementWriter()).write(rootElement, wri, 0, " "); wri.flush(); } catch (IOException exc) { throw new BuildException("Unable to write log file", exc); } finally { if (out != System.out && out != System.err) { if (wri != null) { try { wri.close(); } catch (IOException e) { // ignore } } } } } }
/** The whole testsuite ended. */ public void endTestSuite(JUnitTest suite) throws BuildException { String newLine = System.getProperty("line.separator"); StringBuffer sb = new StringBuffer("Testsuite: "); sb.append(suite.getName()); sb.append(newLine); sb.append("Tests run: "); sb.append(suite.runCount()); sb.append(", Failures: "); sb.append(suite.failureCount()); sb.append(", Errors: "); sb.append(suite.errorCount()); sb.append(", Time elapsed: "); sb.append(nf.format(suite.getRunTime() / 1000.0)); sb.append(" sec"); sb.append(newLine); // append the err and output streams to the log if (systemOutput != null && systemOutput.length() > 0) { sb.append("------------- Standard Output ---------------") .append(newLine) .append(systemOutput) .append("------------- ---------------- ---------------") .append(newLine); } if (systemError != null && systemError.length() > 0) { sb.append("------------- Standard Error -----------------") .append(newLine) .append(systemError) .append("------------- ---------------- ---------------") .append(newLine); } sb.append(newLine); if (out != null) { try { out.write(sb.toString().getBytes()); wri.close(); out.write(inner.toString().getBytes()); out.flush(); } catch (IOException ioex) { throw new BuildException("Unable to write output", ioex); } finally { if (out != System.out && out != System.err) { try { out.close(); } catch (IOException e) { } } } } }
/** * The whole testsuite ended. * * @param suite the testsuite. * @throws BuildException if there is an error. */ public void endTestSuite(JUnitTest suite) throws BuildException { String newLine = System.getProperty("line.separator"); StringBuffer sb = new StringBuffer("Tests run: "); sb.append(suite.runCount()); sb.append(", Failures: "); sb.append(suite.failureCount()); sb.append(", Errors: "); sb.append(suite.errorCount()); sb.append(", Time elapsed: "); sb.append(nf.format(suite.getRunTime() / ONE_SECOND)); sb.append(" sec"); sb.append(newLine); if (withOutAndErr) { if (systemOutput != null && systemOutput.length() > 0) { sb.append("Output:").append(newLine).append(systemOutput).append(newLine); } if (systemError != null && systemError.length() > 0) { sb.append("Error: ").append(newLine).append(systemError).append(newLine); } } try { out.write(sb.toString().getBytes()); out.flush(); } catch (IOException ioex) { throw new BuildException("Unable to write summary output", ioex); } finally { if (out != System.out && out != System.err) { try { out.close(); } catch (IOException e) { // ignore } } } }