olamy commented on code in PR #3651:
URL: https://github.com/apache/maven-surefire/pull/3651#discussion_r4736033575


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java:
##########
@@ -238,30 +263,37 @@ public void testSetCompleted(TestSetReportEntry report) {
     @Override
     public void testStarting(ReportEntry report) {
         getTestSetStats(report).testStart();
+        Long testRunId = report.getTestRunId();
+        if (testRunId != null) {
+            synchronized (lock) {
+                // the test also gets what was printed since the previous 
test, like the output of @BeforeAll
+                runningTestsOutput.computeIfAbsent(testRunId, id -> 
takeSharedOutput());

Review Comment:
   Thanks, done in 8cc278f91. Each test class that is running now has its own 
pending buffers. Output printed outside a test lands there: `@BeforeAll`, while 
JUnit builds the test instance, or between two tests (the thread still has the 
id of the class or of its last test). The next test of that class takes it, and 
so does a skipped test that never started. So A's `@BeforeAll` output no longer 
ends up in B's report. Output from a thread with no run id goes to the test 
that started last, so it isn't lost. `testSetCompleted` now takes its own 
class's buffers under the lock. When only one class runs, it also gets what was 
printed before it started, so sequential runs work as before. 
`TestSetRunListenerTest` covers these cases.
   



-- 
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]

Reply via email to