コード例 #1
0
  /** 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 testsuite started.
   *
   * @param suite the testsuite.
   */
  public void startTestSuite(JUnitTest suite) {
    String newLine = System.getProperty("line.separator");
    StringBuffer sb = new StringBuffer("Running ");
    sb.append(suite.getName());
    sb.append(newLine);

    try {
      out.write(sb.toString().getBytes());
      out.flush();
    } catch (IOException ioex) {
      throw new BuildException("Unable to write summary output", ioex);
    }
  }
コード例 #3
0
  /** The whole testsuite started. */
  public void startTestSuite(JUnitTest suite) {
    doc = getDocumentBuilder().newDocument();
    rootElement = doc.createElement(TESTSUITE);
    rootElement.setAttribute(ATTR_NAME, suite.getName());

    // Output properties
    Element propsElement = doc.createElement(PROPERTIES);
    rootElement.appendChild(propsElement);
    Properties props = suite.getProperties();
    if (props != null) {
      Enumeration e = props.propertyNames();
      while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        Element propElement = doc.createElement(PROPERTY);
        propElement.setAttribute(ATTR_NAME, name);
        propElement.setAttribute(ATTR_VALUE, props.getProperty(name));
        propsElement.appendChild(propElement);
      }
    }
  }