|
@@ -1,5 +1,5 @@ |
|
|
/* |
|
|
/* |
|
|
* Copyright 2000-2004 The Apache Software Foundation |
|
|
|
|
|
|
|
|
* Copyright 2000-2005 The Apache Software Foundation |
|
|
* |
|
|
* |
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
* you may not use this file except in compliance with the License. |
|
|
* you may not use this file except in compliance with the License. |
|
@@ -49,6 +49,9 @@ import org.w3c.dom.Text; |
|
|
|
|
|
|
|
|
public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstants { |
|
|
public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstants { |
|
|
|
|
|
|
|
|
|
|
|
/** constant for unnnamed testsuites/cases */ |
|
|
|
|
|
private static final String UNKNOWN = "unknown"; |
|
|
|
|
|
|
|
|
private static DocumentBuilder getDocumentBuilder() { |
|
|
private static DocumentBuilder getDocumentBuilder() { |
|
|
try { |
|
|
try { |
|
|
return DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
|
|
return DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
|
@@ -103,7 +106,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan |
|
|
public void startTestSuite(JUnitTest suite) { |
|
|
public void startTestSuite(JUnitTest suite) { |
|
|
doc = getDocumentBuilder().newDocument(); |
|
|
doc = getDocumentBuilder().newDocument(); |
|
|
rootElement = doc.createElement(TESTSUITE); |
|
|
rootElement = doc.createElement(TESTSUITE); |
|
|
rootElement.setAttribute(ATTR_NAME, suite.getName()); |
|
|
|
|
|
|
|
|
String n = suite.getName(); |
|
|
|
|
|
rootElement.setAttribute(ATTR_NAME, n == null ? UNKNOWN : n); |
|
|
|
|
|
|
|
|
//add the timestamp |
|
|
//add the timestamp |
|
|
final String timestamp = DateUtils.format(new Date(), |
|
|
final String timestamp = DateUtils.format(new Date(), |
|
@@ -190,8 +194,9 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan |
|
|
Element currentTest = null; |
|
|
Element currentTest = null; |
|
|
if (!failedTests.containsKey(test)) { |
|
|
if (!failedTests.containsKey(test)) { |
|
|
currentTest = doc.createElement(TESTCASE); |
|
|
currentTest = doc.createElement(TESTCASE); |
|
|
|
|
|
String n = JUnitVersionHelper.getTestCaseName(test); |
|
|
currentTest.setAttribute(ATTR_NAME, |
|
|
currentTest.setAttribute(ATTR_NAME, |
|
|
JUnitVersionHelper.getTestCaseName(test)); |
|
|
|
|
|
|
|
|
n == null ? UNKNOWN : n); |
|
|
// a TestSuite can contain Tests from multiple classes, |
|
|
// a TestSuite can contain Tests from multiple classes, |
|
|
// even tests with the same name - disambiguate them. |
|
|
// even tests with the same name - disambiguate them. |
|
|
currentTest.setAttribute(ATTR_CLASSNAME, |
|
|
currentTest.setAttribute(ATTR_CLASSNAME, |
|
|