Author: julien(a)jboss.com
Date: 2007-10-22 09:31:27 -0400 (Mon, 22 Oct 2007)
New Revision: 8735
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java
Log:
skip empty reports
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java 2007-10-22
13:22:14 UTC (rev 8734)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java 2007-10-22
13:31:27 UTC (rev 8735)
@@ -109,60 +109,64 @@
{
TestSuiteReport report = entry.getValue();
- report.elements.add(testsuitesDocument.createElement(XMLConstants.PROPERTIES));
- Element systemError =
testsuitesDocument.createElement(XMLConstants.SYSTEM_ERR);
-
systemError.appendChild(testsuitesDocument.createCDATASection(report.err.toString()));
- report.elements.add(systemError);
- Element systemOutElement =
testsuitesDocument.createElement(XMLConstants.SYSTEM_OUT);
-
systemOutElement.appendChild(testsuitesDocument.createCDATASection(report.out.toString()));
- report.elements.add(systemOutElement);
+ // We filter and keep only meaningful results
+ if (report.elements.size() > 0)
+ {
+
report.elements.add(testsuitesDocument.createElement(XMLConstants.PROPERTIES));
+ Element systemError =
testsuitesDocument.createElement(XMLConstants.SYSTEM_ERR);
+
systemError.appendChild(testsuitesDocument.createCDATASection(report.err.toString()));
+ report.elements.add(systemError);
+ Element systemOutElement =
testsuitesDocument.createElement(XMLConstants.SYSTEM_OUT);
+
systemOutElement.appendChild(testsuitesDocument.createCDATASection(report.out.toString()));
+ report.elements.add(systemOutElement);
- //
- Element testSuiteElt =
testsuitesDocument.createElement(XMLConstants.TESTSUITE);
+ //
+ Element testSuiteElt =
testsuitesDocument.createElement(XMLConstants.TESTSUITE);
- //
- testSuiteElt.setAttribute(XMLConstants.HOSTNAME, getHostName());
- testSuiteElt.setAttribute(XMLConstants.ATTR_PACKAGE,
entry.getKey().packageName);
- testSuiteElt.setAttribute(XMLConstants.ATTR_NAME, entry.getKey().className);
- testSuiteElt.setAttribute(XMLConstants.ATTR_TESTS,
Integer.toString(report.tests));
- testSuiteElt.setAttribute(XMLConstants.ATTR_ERRORS,
Integer.toString(report.errors));
- testSuiteElt.setAttribute(XMLConstants.ATTR_FAILURES,
Integer.toString(report.failures));
- testSuiteElt.setAttribute(XMLConstants.ATTR_TIME,
DURATION_FORMAT.format(report.durationMillis / 1000.0));
+ //
+ testSuiteElt.setAttribute(XMLConstants.HOSTNAME, getHostName());
+ testSuiteElt.setAttribute(XMLConstants.ATTR_PACKAGE,
entry.getKey().packageName);
+ testSuiteElt.setAttribute(XMLConstants.ATTR_NAME, entry.getKey().className);
+ testSuiteElt.setAttribute(XMLConstants.ATTR_TESTS,
Integer.toString(report.tests));
+ testSuiteElt.setAttribute(XMLConstants.ATTR_ERRORS,
Integer.toString(report.errors));
+ testSuiteElt.setAttribute(XMLConstants.ATTR_FAILURES,
Integer.toString(report.failures));
+ testSuiteElt.setAttribute(XMLConstants.ATTR_TIME,
DURATION_FORMAT.format(report.durationMillis / 1000.0));
- //
- for (Element elt : report.elements)
- {
- testSuiteElt.appendChild(elt);
- }
+ //
+ for (Element elt : report.elements)
+ {
+ testSuiteElt.appendChild(elt);
+ }
- //
- if (xmlReportDir != null)
- {
- Document tmp = createDocument();
- Element copy = (Element)tmp.importNode(testSuiteElt, true);
- tmp.appendChild(copy);
- String a = copy.getAttribute("package");
- String b = copy.getAttribute("name");
- String c = a.length() == 0 ? b : a + "." + b;
- copy.setAttribute("name", c);
- copy.removeAttribute("package");
- try
+ //
+ if (xmlReportDir != null)
{
- File f = new File(xmlReportDir, TEST_FILE_NAME_PREFIX + c +
".xml");
- if (!f.exists())
+ Document tmp = createDocument();
+ Element copy = (Element)tmp.importNode(testSuiteElt, true);
+ tmp.appendChild(copy);
+ String a = copy.getAttribute("package");
+ String b = copy.getAttribute("name");
+ String c = a.length() == 0 ? b : a + "." + b;
+ copy.setAttribute("name", c);
+ copy.removeAttribute("package");
+ try
{
- f.createNewFile();
+ File f = new File(xmlReportDir, TEST_FILE_NAME_PREFIX + c +
".xml");
+ if (!f.exists())
+ {
+ f.createNewFile();
+ }
+ serializeNode(tmp, f);
}
- dump(tmp, f);
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
}
- catch (IOException e)
- {
- e.printStackTrace();
- }
+
+ //
+ testsuitesElement.appendChild(testSuiteElt);
}
-
- //
- testsuitesElement.appendChild(testSuiteElt);
}
//
@@ -187,7 +191,7 @@
//
File tmp = new File(htmlReportDir, "TESTS-TestSuites.xml");
- dump(testsuitesElement, tmp);
+ serializeNode(testsuitesElement, tmp);
}
}
@@ -250,7 +254,7 @@
report.durationMillis += testSuite.durationMillis;
}
- private void dump(Node node, File dest)
+ private void serializeNode(Node node, File dest)
{
try
{
@@ -294,7 +298,7 @@
failureType = XMLConstants.ERROR;
}
- test.appendChild(addError(failureType, failure.getStackTrace()));
+ test.appendChild(addGeneralError(failureType, failure.getStackTrace()));
}
//
@@ -317,7 +321,7 @@
}
- private Element addError(String type, Throwable t)
+ private Element addGeneralError(String type, Throwable t)
{
Element error = testsuitesDocument.createElement(type);
@@ -453,5 +457,4 @@
private long durationMillis;
}
-
}
\ No newline at end of file
Show replies by date