Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1614

JUnit Runner that writes to System.out corrupts Surefire's STDOUT when using JUnit's Vintage Engine

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.22.1, 3.0.0-M2
    • 2.22.2, 3.0.0-M3
    • JUnit 5.x support
    • None

    Description

      When JUnit Jupiter's Vintage Engine is used to run tests written using the JUnit 4 API, output to the console from a TestRunner results in Surefire's STDOUT being corrupted:

      [WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file […]

      Note that the test runner is simply calling System.out. This is to simulate the real world setup where the runner performs some logging that ultimately results in a console appender calling System.out. The same arrangement does not cause a problem when run using JUnit 4. An initial investigation suggests that the Vintage Engine calls the custom TestRunner earlier and, it would appear, at a time when Surefire cannot tolerate output to System.out.

      I have attached a minimal project that reproduces the problem. Running ./mvnw -Pjunit5 test will reproduce the corruption. Running ./mvnw -Pjunit4 test will not.

      Attachments

        1. surefire-stream-corruption-bug.zip
          50 kB
          Andy Wilkinson

        Issue Links

          Activity

            People

              sor Christian Stein
              awilkinson Andy Wilkinson
              Votes:
              2 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m