Surefire Maven plugin: “Corrupted STDOUT by directly writing to native stream in forked JVM”

前端 未结 7 1605
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 01:23

My JUnit tests are failing when running them through Maven and the Surefire plugin (version information below). I see the error message:

Corrupted STDOUT by direc         


        
7条回答
  •  无人及你
    2021-02-01 01:55

    I was running into this issue when running my Junit tests using a custom Runner. If I made any output to System.out or System.err in my custom runner or in my test class, this exact warning would show up. In my case the problem was not caused by some older Jacoco version. Updating the surefire plugin to version 2.22.2 or the more recent 3.0.0-M4 did not solve the issue.

    According to the Jira issue SUREFIRE-1614, the problem will be fixed in the 3.0.0-M5 release of the maven-surefire-plugin (not released as of May 21st 2020).

    Update The Maven Surefire plugin version 3.0.0-M5 has now been released. In your pom.xml you can do the following:

        
          maven-surefire-plugin
          3.0.0-M5
          
            
            
          
        
    

    Original answer

    If you cannot wait for the release of the 3.0.0-M5 plugin, you can use the "SNAPSHOT" version of the plugin. It did fix the issue for me. You have to enable some specific setting in the plugin so that the plugin uses TCP instead of the standard output/error to obtain the events raised in your tests. Configuration changes below:

    In my pom.xml:

    
    
    
      4.0.0
    
    ...
      
      
        
          apache.snapshots
          https://repository.apache.org/snapshots/
        
      
    
      
        
          
        ...
        maven-surefire-plugin
          
          3.0.0-SNAPSHOT
          
            
            
          
        
    
    

提交回复
热议问题