You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Christian Stein (JIRA)" <ji...@apache.org> on 2018/12/02 13:37:00 UTC

[jira] [Updated] (SUREFIRE-1603) Output captured under wrong test in JUnit 5 parallel mode

     [ https://issues.apache.org/jira/browse/SUREFIRE-1603?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Stein updated SUREFIRE-1603:
--------------------------------------
    Issue Type: Improvement  (was: Bug)

> Output captured under wrong test in JUnit 5 parallel mode
> ---------------------------------------------------------
>
>                 Key: SUREFIRE-1603
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1603
>             Project: Maven Surefire
>          Issue Type: Improvement
>          Components: JUnit 5.x support
>    Affects Versions: 3.0.0-M1, 2.22.1
>            Reporter: John Knight
>            Priority: Major
>
> Using JUnit 5.31 with the following configuration:
> {noformat}
> <configurationParameters>
>     junit.jupiter.execution.parallel.enabled = true
>     junit.jupiter.execution.parallel.config.dynamic.factor = 8
>     junit.jupiter.extensions.autodetection.enabled = true
> </configurationParameters>{noformat}
> and the following tests (for demonstration purposes)
> {noformat}
> public class AppTest
> {
>     @Test
>     public void mogbyTrue()
>     {
>         for (int i = 0; i < 5; i++) {
>             System.out.println("mogby " + Thread.currentThread().getName());
>         }
>         assertTrue( false );
>     }
>     @Test
>     public void kermitTrue()
>     {
>         for (int i = 0; i < 5; i++) {
>             System.out.println("kermit " + Thread.currentThread().getName());
>         }
>         assertTrue( false );
>     }{noformat}
> When the tests are executed via mvn test, the messages from both tests appear under the output for the first test:
> {noformat}
> <testcase name="mogbyTrue" classname="com.foo.logtest.AppTest" time="0.013">
>     <failure message="expected: ...
>     </failure>
> <system-out><![CDATA[mogby ForkJoinPool-1-worker-43
> kermit ForkJoinPool-1-worker-50
> mogby ForkJoinPool-1-worker-43
> kermit ForkJoinPool-1-worker-50
> mogby ForkJoinPool-1-worker-43
> kermit ForkJoinPool-1-worker-50
> mogby ForkJoinPool-1-worker-43
> kermit ForkJoinPool-1-worker-50
> mogby ForkJoinPool-1-worker-43
> kermit ForkJoinPool-1-worker-50
> ]]></system-out>
> </testcase>{noformat}
> If I change the code to use TestReporter.publishEntry(), the messages don't make their way into the surefire reports at all.
> If I configure Capturing stdout - [https://junit.org/junit5/docs/snapshot/user-guide/#running-tests-capturing-output] - The output for both tests is still captured within the <system-out> field of the first test, but in a different order:
> {noformat}
> <system-out><![CDATA[kermit ForkJoinPool-1-worker-50
> kermit ForkJoinPool-1-worker-50
> kermit ForkJoinPool-1-worker-50
> kermit ForkJoinPool-1-worker-50
> kermit ForkJoinPool-1-worker-50
> mogby ForkJoinPool-1-worker-43
> mogby ForkJoinPool-1-worker-43
> mogby ForkJoinPool-1-worker-43
> mogby ForkJoinPool-1-worker-43
> mogby ForkJoinPool-1-worker-43
> ]]></system-out>{noformat}
> The original use case for this, is that we have a whole suite of tests running via Jenkins, so when tests fail, it's really difficult to see what the actual problem is, as the logging is out of sync.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)