Copilot commented on code in PR #3651:
URL: https://github.com/apache/maven-surefire/pull/3651#discussion_r4738218575
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java:
##########
@@ -183,6 +210,48 @@ public void writeTestOutput(TestOutputReportEntry
reportEntry) {
}
}
+ private TestOutput outputOf(Long testRunId) {
+ if (testRunId != null) {
+ TestOutput testOutput = runningTestsOutput.get(testRunId);
+ if (testOutput != null) {
+ return testOutput;
+ }
+ // printed outside a test, in @BeforeAll or between two tests, the
thread still has the id of the last one
+ testOutput = classOutput.get(classOfRunId.get(testRunId));
+ if (testOutput != null) {
+ return testOutput;
+ }
+ }
+ // A thread the provider doesn't know, like a logger. The test that
started last gets it, so it isn't lost.
+ TestOutput lastStarted = null;
+ for (TestOutput testOutput : runningTestsOutput.values()) {
+ lastStarted = testOutput;
+ }
+ if (lastStarted == null && classOutput.size() == 1) {
+ return classOutput.values().iterator().next();
+ }
+ return lastStarted;
Review Comment:
With multiple classes in `@BeforeAll` and no running test methods, untagged
output goes into shared buffers that neither class consumes. These lines
disappear from both XML reports or appear under a later, unrelated class. Drain
unassigned output into a report using an explicit fallback policy, and add a
regression case that logs after both class-start events but before either
method starts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]