diff --git a/changelog.html b/changelog.html
index 340c5d07cc78736e683a5e2f9cd81cf844c661f1..9744d9c81525486ba8d8dbbdbca037c4f2454763 100644
--- a/changelog.html
+++ b/changelog.html
@@ -69,6 +69,9 @@ Upcoming changes
Fixed Maven build error if headless option is set and MAVEN_OPTS empty
(issue 10375)
+
+ Tests not recognized as failed if test initialization failed
+ (issue 6700)
diff --git a/core/src/main/java/hudson/tasks/junit/SuiteResult.java b/core/src/main/java/hudson/tasks/junit/SuiteResult.java
index 06761acc9745690f071e6ecf8eb9b0efa54917d9..c924cdb978aad2f803be90feff0f646b08b32547 100644
--- a/core/src/main/java/hudson/tasks/junit/SuiteResult.java
+++ b/core/src/main/java/hudson/tasks/junit/SuiteResult.java
@@ -123,7 +123,8 @@ public final class SuiteResult implements Serializable {
parseSuite(xmlReport, keepLongStdio, r, suite);
// child test cases
- if (root.element("testcase")!=null)
+ // FIXME: do this also if no testcases!
+ if (root.element("testcase")!=null || root.element("error")!=null)
r.add(new SuiteResult(xmlReport, root, keepLongStdio));
}
@@ -155,11 +156,11 @@ public final class SuiteResult implements Serializable {
}
for (Element e : (List)suite.elements("testcase")) {
- // https://hudson.dev.java.net/issues/show_bug.cgi?id=1233 indicates that
+ // https://issues.jenkins-ci.org/browse/JENKINS-1233 indicates that
// when is present, we are better off using @classname on the
// individual testcase class.
- // https://hudson.dev.java.net/issues/show_bug.cgi?id=1463 indicates that
+ // https://issues.jenkins-ci.org/browse/JENKINS-1463 indicates that
// @classname may not exist in individual testcase elements. We now
// also test if the testsuite element has a package name that can be used
// as the class name instead of the file name which is default.
@@ -168,7 +169,7 @@ public final class SuiteResult implements Serializable {
classname = suite.attributeValue("name");
}
- // https://hudson.dev.java.net/issues/show_bug.cgi?id=1233 and
+ // https://issues.jenkins-ci.org/browse/JENKINS-1233 and
// http://www.nabble.com/difference-in-junit-publisher-and-ant-junitreport-tf4308604.html#a12265700
// are at odds with each other --- when both are present,
// one wants to use @name from ,
diff --git a/test/src/test/java/hudson/tasks/junit/SuiteResultTest.java b/test/src/test/java/hudson/tasks/junit/SuiteResultTest.java
old mode 100755
new mode 100644
index 8383b103bc940055be1b46a018548b0c140f8087..468ceff20e6e2a78d4e0bced03821774831eccfa
--- a/test/src/test/java/hudson/tasks/junit/SuiteResultTest.java
+++ b/test/src/test/java/hudson/tasks/junit/SuiteResultTest.java
@@ -27,23 +27,25 @@ import java.io.File;
import java.util.List;
import java.net.URISyntaxException;
-import junit.framework.TestCase;
-
import hudson.XmlFile;
-import org.jvnet.hudson.test.HudsonTestCase;
+
+import org.jvnet.hudson.test.Bug;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.Writer;
+import junit.framework.TestCase;
+
/**
* Test cases for parsing JUnit report XML files.
* As there are no XML schema for JUnit xml files, Hudson needs to handle
* varied xml files.
*
* @author Erik Ramfelt
+ * @author Christoph Kutzinski
*/
-public class SuiteResultTest extends HudsonTestCase {
+public class SuiteResultTest extends TestCase {
private File getDataFile(String name) throws URISyntaxException {
return new File(SuiteResultTest.class.getResource(name).toURI());
@@ -179,4 +181,19 @@ public class SuiteResultTest extends HudsonTestCase {
}
}
+
+ /**
+ * When the testcase fails to initialize (exception in constructor or @Before)
+ * there is no 'testcase' element at all.
+ */
+ @Bug(6700)
+ public void testErrorInTestInitialization() throws Exception {
+ SuiteResult suiteResult = parseOne(getDataFile("junit-report-6700.xml"));
+
+ assertEquals(1, suiteResult.getCases().size());
+
+ CaseResult result = suiteResult.getCases().get(0);
+ assertEquals(1, result.getFailCount());
+ assertTrue(result.getErrorStackTrace() != null);
+ }
}