[jira] [Commented] (SUREFIRE-2232) StatelessXmlReporter fails to process failed result without a throwable
[ https://issues.apache.org/jira/browse/SUREFIRE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805725#comment-17805725 ] ASF GitHub Bot commented on SUREFIRE-2232: -- dr29bart commented on code in PR #716: URL: https://github.com/apache/maven-surefire/pull/716#discussion_r1449170752 ## maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java: ## @@ -451,7 +451,9 @@ private static void getTestProblems( String type = delimiter == -1 ? stackTrace : stackTrace.substring(0, delimiter); ppw.addAttribute("type", type); } else { -ppw.addAttribute("type", new StringTokenizer(stackTrace).nextToken()); +ppw.addAttribute( +"type", +isBlank(stackTrace) ? "UndefinedException" : new StringTokenizer(stackTrace).nextToken()); Review Comment: Do you mean `indexOf` approach or `to use value as is`? I didn't want to leave a chance for `type` to be null. What non-null value can be used here? The `stackTrace` StatelessXmlReporter#439 var may be null: ``` public String getStackTrace(boolean trimStackTrace) { StackTraceWriter w = original.getStackTraceWriter(); return w == null ? null : (trimStackTrace ? w.writeTrimmedTraceToString() : w.writeTraceToString()); } ``` At the same time surefire's XSD requires `type` XSD ```xml ``` The goal is to handle stack traces like: ``` // has message junit.framework.ComparisonFailure: Expected :fail at foo Actual :faild at foo // does not have message java.lang.AssertionError at org.junit.Assert.fail(Assert.java:87) at org.junit.Assert.fail(Assert.java:96) // or stack trace is missing (empty String) ``` Please, let me know if this alternative is more preferable: Option A ```java if (report.getStackTraceWriter() != null) { //noinspection ThrowableResultOfMethodCallIgnored SafeThrowable t = report.getStackTraceWriter().getThrowable(); if (t != null) { int delimiter = StringUtils.indexOfAny(stackTrace, ":", "\t", "\n", "\r", "\f"); String type = delimiter == -1 ? stackTrace : stackTrace.substring(0, delimiter); ppw.addAttribute("type", Objects.toString(type, "UndefinedException")); } } ``` Option B ```java SafeThrowable t = report.getStackTraceWriter().getThrowable(); if (t != null) { if (t.getMessage() != null) { int delimiter = stackTrace.indexOf(":"); String type = delimiter == -1 ? stackTrace : stackTrace.substring(0, delimiter); ppw.addAttribute("type", type); } else { ppw.addAttribute( "type", isBlank(stackTrace) ? stackTrace : new StringTokenizer(stackTrace).nextToken()); } } ``` Option C ```java SafeThrowable t = report.getStackTraceWriter().getThrowable(); if (t != null) { if (t.getMessage() != null) { int delimiter = stackTrace.indexOf(":"); String type = delimiter == -1 ? stackTrace : stackTrace.substring(0, delimiter); ppw.addAttribute("type", type); } else { int delimiter = StringUtils.indexOfAny(stackTrace, "\t", "\n", "\r", "\f"); String type = delimiter == -1 ? stackTrace : stackTrace.substring(0, delimiter); ppw.addAttribute("type", type); } } > StatelessXmlReporter fails to process failed result without a throwable > --- > > Key: SUREFIRE-2232 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2232 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin >Affects Versions: 3.0.0-M6, 3.2.3 >Reporter: Artem Yak >Priority: Minor > Fix For: waiting-for-feedback > > > > A regression bug appeared
[jira] [Commented] (SUREFIRE-2232) StatelessXmlReporter fails to process failed result without a throwable
[ https://issues.apache.org/jira/browse/SUREFIRE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805689#comment-17805689 ] ASF GitHub Bot commented on SUREFIRE-2232: -- michael-o commented on code in PR #716: URL: https://github.com/apache/maven-surefire/pull/716#discussion_r1449098296 ## maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java: ## @@ -451,7 +451,9 @@ private static void getTestProblems( String type = delimiter == -1 ? stackTrace : stackTrace.substring(0, delimiter); ppw.addAttribute("type", type); } else { -ppw.addAttribute("type", new StringTokenizer(stackTrace).nextToken()); +ppw.addAttribute( +"type", +isBlank(stackTrace) ? "UndefinedException" : new StringTokenizer(stackTrace).nextToken()); Review Comment: Why don't you reuse the approach from line 451? > StatelessXmlReporter fails to process failed result without a throwable > --- > > Key: SUREFIRE-2232 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2232 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin >Affects Versions: 3.0.0-M6, 3.2.3 >Reporter: Artem Yak >Priority: Minor > Fix For: waiting-for-feedback > > > > A regression bug appeared in 3.0.0-M6: > A testNG test class has a listener which updates results from SUCCESS to > FAILURE: > > {noformat} > @Override > public void onTestSuccess(ITestResult result) { > result.setStatus(ITestResult.FAILURE); > result.getTestContext().getPassedTests().removeResult(result); > result.getTestContext().getFailedTests().addResult(result); > }{noformat} > > Surefire fails to process a failed test result without a throwable and > reports 0 total tests. > {code:java} > 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.(ThreadedStreamConsumer.java:59) > at > org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.(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) > {code} > > Reproducible unit test. > {code:java} > 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,
[jira] [Commented] (SUREFIRE-2232) StatelessXmlReporter fails to process failed result without a throwable
[ https://issues.apache.org/jira/browse/SUREFIRE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805682#comment-17805682 ] Artem Yak commented on SUREFIRE-2232: - sure: https://github.com/apache/maven-surefire/pull/716 > StatelessXmlReporter fails to process failed result without a throwable > --- > > Key: SUREFIRE-2232 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2232 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin >Affects Versions: 3.0.0-M6, 3.2.3 >Reporter: Artem Yak >Priority: Minor > Fix For: waiting-for-feedback > > > > A regression bug appeared in 3.0.0-M6: > A testNG test class has a listener which updates results from SUCCESS to > FAILURE: > > {noformat} > @Override > public void onTestSuccess(ITestResult result) { > result.setStatus(ITestResult.FAILURE); > result.getTestContext().getPassedTests().removeResult(result); > result.getTestContext().getFailedTests().addResult(result); > }{noformat} > > Surefire fails to process a failed test result without a throwable and > reports 0 total tests. > {code:java} > 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.(ThreadedStreamConsumer.java:59) > at > org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.(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) > {code} > > Reproducible unit test. > {code:java} > 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); > } > } {code} > > > > {code:java} > 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) >
[jira] [Commented] (SUREFIRE-2232) StatelessXmlReporter fails to process failed result without a throwable
[ https://issues.apache.org/jira/browse/SUREFIRE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805681#comment-17805681 ] ASF GitHub Bot commented on SUREFIRE-2232: -- dr29bart opened a new pull request, #716: URL: https://github.com/apache/maven-surefire/pull/716 > A regression bug appeared in 3.0.0-M6: > > A testNG test class has a listener which updates results from SUCCESS to FAILURE: ``` java @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.(ThreadedStreamConsumer.java:59) at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.(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) ... Suppressed: java.util.NoSuchElementException at java.base/java.util.StringTokenizer.nextToken(StringTokenizer.java:347) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.getTestProblems(StatelessXmlReporter.java:454) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.serializeTestClassWithoutRerun(StatelessXmlReporter.java:221) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.serializeTestClass(StatelessXmlReporter.java:211) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.testSetCompleted(StatelessXmlReporter.java:161) at org.apache.maven.plugin.surefire.report.StatelessXmlReporter.testSetCompleted(StatelessXmlReporter.java:85) at org.apache.maven.plugin.surefire.report.TestSetRunListener.testSetCompleted(TestSetRunListener.java:193) at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$TestSetCompletedListener.handle(ForkClient.java:143) ``` The fix is to set a hardcoded value - `UndefinedException` as `error type` in case stack trace is empty. checklist Following this checklist to help us incorporate your contribution quickly and easily: - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SUREFIRE) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [x] Format the pull request title like `[SUREFIRE-XXX] - Fixes bug in ApproximateQuantiles`, where you replace `SUREFIRE-XXX` with the appropriate JIRA issue. Best practice is to use the JIRA issue title in the pull request title and in the first line of the commit message. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [x] You have run the integration tests successfully (`mvn -Prun-its clean install`). If your pull request is about ~20 lines of code you don't need to sign an [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure please ask on the developers list. To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) you have to acknowledge this by using the following check-box. - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). > StatelessXmlReporter fails to process failed result without a throwable > --- > > Key: SUREFIRE-2232 > URL:
[jira] [Commented] (SUREFIRE-2232) StatelessXmlReporter fails to process failed result without a throwable
[ https://issues.apache.org/jira/browse/SUREFIRE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805239#comment-17805239 ] Michael Osipov commented on SUREFIRE-2232: -- Do you think you could work our a PR? > StatelessXmlReporter fails to process failed result without a throwable > --- > > Key: SUREFIRE-2232 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2232 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin >Affects Versions: 3.0.0-M6, 3.2.3 >Reporter: Artem Yak >Priority: Minor > Fix For: waiting-for-feedback > > > > A regression bug appeared in 3.0.0-M6: > A testNG test class has a listener which updates results from SUCCESS to > FAILURE: > > {noformat} > @Override > public void onTestSuccess(ITestResult result) { > result.setStatus(ITestResult.FAILURE); > result.getTestContext().getPassedTests().removeResult(result); > result.getTestContext().getFailedTests().addResult(result); > }{noformat} > > Surefire fails to process a failed test result without a throwable and > reports 0 total tests. > {code:java} > 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.(ThreadedStreamConsumer.java:59) > at > org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.(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) > {code} > > Reproducible unit test. > {code:java} > 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); > } > } {code} > > > > {code:java} > 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 >
[jira] [Commented] (SUREFIRE-2232) StatelessXmlReporter fails to process failed result without a throwable
[ https://issues.apache.org/jira/browse/SUREFIRE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805177#comment-17805177 ] Artem Yak commented on SUREFIRE-2232: - [~michael-o] it fails the same way in 3.2.5 and the unit test also fails with 3.2.6-SNAPSHOT {noformat} [WARNING] ForkStarter IOException: java.util.NoSuchElementException. See the dump file C:\workspaces\repo\pqa\target\surefire-reports\2024-01-10T08-52-22_132-jvmRun1.dumpstream [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] [INFO] BUILD SUCCESS [INFO] [INFO] Total time: 51.343 s {noformat} > StatelessXmlReporter fails to process failed result without a throwable > --- > > Key: SUREFIRE-2232 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2232 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin >Affects Versions: 3.0.0-M6, 3.2.3 >Reporter: Artem Yak >Priority: Minor > Fix For: waiting-for-feedback > > > > A regression bug appeared in 3.0.0-M6: > A testNG test class has a listener which updates results from SUCCESS to > FAILURE: > > {noformat} > @Override > public void onTestSuccess(ITestResult result) { > result.setStatus(ITestResult.FAILURE); > result.getTestContext().getPassedTests().removeResult(result); > result.getTestContext().getFailedTests().addResult(result); > }{noformat} > > Surefire fails to process a failed test result without a throwable and > reports 0 total tests. > {code:java} > 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.(ThreadedStreamConsumer.java:59) > at > org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.(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) > {code} > > Reproducible unit test. > {code:java} > 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); > } > } {code} > > > > {code:java} > java.util.NoSuchElementException > at
[jira] [Commented] (SUREFIRE-2232) StatelessXmlReporter fails to process failed result without a throwable
[ https://issues.apache.org/jira/browse/SUREFIRE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17804989#comment-17804989 ] Michael Osipov commented on SUREFIRE-2232: -- Please try 3.2.5. > StatelessXmlReporter fails to process failed result without a throwable > --- > > Key: SUREFIRE-2232 > URL: https://issues.apache.org/jira/browse/SUREFIRE-2232 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin >Affects Versions: 3.0.0-M6, 3.2.3 >Reporter: Artem Yak >Priority: Minor > > > A regression bug appeared in 3.0.0-M6: > A testNG test class has a listener which updates results from SUCCESS to > FAILURE: > > {noformat} > @Override > public void onTestSuccess(ITestResult result) { > result.setStatus(ITestResult.FAILURE); > result.getTestContext().getPassedTests().removeResult(result); > result.getTestContext().getFailedTests().addResult(result); > }{noformat} > > Surefire fails to process a failed test result without a throwable and > reports 0 total tests. > {code:java} > 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.(ThreadedStreamConsumer.java:59) > at > org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer.(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) > {code} > > Reproducible unit test. > {code:java} > 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); > } > } {code} > > > > {code:java} > 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 >