olamy opened a new issue, #3662:
URL: https://github.com/apache/maven-surefire/issues/3662
### Affected version
3.6.1
### Bug description
When test classes run in parallel, some output still ends up in the report
of the wrong class.
Surefire uses an id on the thread to know which test printed a line. Two
cases go wrong:
1. A thread started by a test has no id. Its output goes to the test that
started last, which can be in another class. This includes
`assertTimeoutPreemptively` and `@Timeout(threadMode = SEPARATE_THREAD)`, which
run the test body on their own thread.
```java
class ATest {
@Test
void a() {
assertTimeoutPreemptively(ofSeconds(5), () ->
System.out.println("inside A"));
}
}
```
If a test of BTest started after `a`, `inside A` ends up in
`TEST-BTest.xml`.
2. With `junit.jupiter.execution.parallel.mode.default=concurrent`, a thread
still has the id of the test it ran before. What a class prints while its test
instance is created, in its constructor or a Spring context load, can go to
that other test's class.
#3651 made this better, but didn't fix these two cases.
A fix could check the stack of the output, which Surefire already has.
`ConsoleOutputFileReporter` does the same to find the test class.
--
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]