提交 a2c8673d 编写于 作者: C Christoph Kutzinski

[FIXED JENKINS-6700] Failure in test class constructor or @Before method was not reported

上级 343d3ac7
......@@ -69,6 +69,9 @@ Upcoming changes</a>
<li class=bug>
Fixed Maven build error if headless option is set and MAVEN_OPTS empty
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10375">issue 10375</a>)
<li class=bug>
Tests not recognized as failed if test initialization failed
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-6700">issue 6700</a>)
</ul>
</div><!--=TRUNK-END=-->
......
......@@ -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<Element>)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 <testsuites> 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 <testsuite>,
......
......@@ -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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册