Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.0-M6, 3.2.3, 3.2.5
-
None
Description
A regression bug appeared in 3.0.0-M6:
A testNG test class has a listener which updates results from SUCCESS to FAILURE:
@Override public void onTestSuccess(ITestResult result) { result.setStatus(ITestResult.FAILURE); result.getTestContext().getPassedTests().removeResult(result); result.getTestContext().getFailedTests().addResult(result); }
Surefire fails to process a failed test result without a throwable and reports 0 total tests.
ForkStarter IOException: java.util.NoSuchElementException. org.apache.maven.plugin.surefire.booterclient.output.MultipleFailureException: java.util.NoSuchElementException at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.<init>(ThreadedStreamConsumer.java:59) at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.<init>(ThreadedStreamConsumer.java:107) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:546) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:285) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:250)
Reproducible unit test.
package org.apache.maven.plugin.surefire.report; import java.io.File; import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; import junit.framework.TestCase; import org.apache.maven.plugin.surefire.booterclient.output.DeserializedStacktraceWriter; import org.apache.maven.surefire.api.report.SimpleReportEntry; import org.apache.maven.surefire.api.report.StackTraceWriter; import static org.apache.maven.plugin.surefire.report.ReportEntryType.ERROR; import static org.apache.maven.surefire.api.report.RunMode.NORMAL_RUN; @SuppressWarnings({"ResultOfMethodCallIgnored", "checkstyle:magicnumber"}) public class StatelessXmlReporter2Test extends TestCase { private static final String XSD = "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd"; private static final AtomicInteger FOLDER_POSTFIX = new AtomicInteger(); private File reportDir; @Override protected void setUp() throws Exception { File basedir = new File("."); File target = new File(basedir.getCanonicalFile(), "target"); target.mkdir(); String reportRelDir = getClass().getSimpleName() + "-" + FOLDER_POSTFIX.incrementAndGet(); reportDir = new File(target, reportRelDir); reportDir.mkdir(); } @Override protected void tearDown() { } public void testOutputFailedTestWithoutThrowable() { StackTraceWriter stackTraceWriterOne = new DeserializedStacktraceWriter(null, null, ""); WrappedReportEntry testReport = new WrappedReportEntry( new SimpleReportEntry( NORMAL_RUN, 1L, getClass().getName(), null, "a test name", null, stackTraceWriterOne, 5), ERROR, 5, null, null); TestSetStats testSetStats = new TestSetStats(false, false); testSetStats.testError(testReport); StatelessXmlReporter reporter = new StatelessXmlReporter( reportDir, null, false, 1, new HashMap<>(), XSD, "3.0", false, false, false, false); reporter.testSetCompleted(testReport, testSetStats); } }
java.util.NoSuchElementException at java.base/java.util.StringTokenizer.nextToken(StringTokenizer.java:349) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.getTestProblems(StatelessXmlReporter.java:454) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.serializeTestClassWithRerun(StatelessXmlReporter.java:256) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.serializeTestClass(StatelessXmlReporter.java:207) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.testSetCompleted(StatelessXmlReporter.java:161) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter2Test.testOutputFailedTestWithoutThrowable(StatelessXmlReporter2Test.java:72)
Attachments
Issue Links
- requires
-
SUREFIRE-2248 Make "type" attribute on failures and errors in (surefire|failsafe)-test-report schema optional
- Closed
- links to