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

This commit is contained in:
Christoph Kutzinski committed 2011-07-23 11:14:30 +02:00
1 parent 343d3ac722
commit a2c8673da1
3 files changed
+29 -8

No files matched your search

+21 -4
View File
@@ -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);
}
}