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

Logs get dumped to console all at once when the execution is over, instead of being printed in real time

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 3.0.0-M5
    • None
    • Maven Surefire Plugin
    • None
    • Windows 10, Java 11.0.7, Intellij IDEA 2020.3



      I'm working on a test automation project using Maven (with Surefire plugin) and JUnit 5. Since I have very long-running UI scripts (up to 20 minutes), I make intensive use of logging to the console. This is crucial to me, at least in the developing phase of each script. However, logs gets dumped all at once at the end of the execution, instead of being printed in real-time. I realize this makes perfect sense in case of parallel execution (to avoid overlapping issues), but I would like a way to disable this when executing in a serial fashion. I've searched both Surefire and JUnit documentations, but I can't seem to find a way. Any help would be appreciated. This is a very simple dummy project to reproduce the issue:


      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


      import org.junit.jupiter.api.Test;
      public class DummyTest {
          public void ConsoleLoggingTest() {
              System.out.println("STARTING TEST...");
              try { Thread.sleep(30000); } catch (Exception ignored) { } //SIMULATE LONG-RUNNING TASK
              System.out.println("TEST IS FINISHED!");

      I use to execute tests with the mvn test command in my IDE (IntelliJ IDEA). Please note that I used System.out.println() for the sake of simplicity, but I get the same behavior using any logging library, like log4j.

      Another thing worth mentioning is that I get the correct behavior if running the tests through the integrated JUnit plugin in my IDE, instead of running them though Maven Surefire. Also, I get the same exact issue using TestNG.

      I can remember having a similar setup a couple of years ago (Surefire 2.x + JUnit 4) and I've never experienced this issue. Something must have been changed, but I can't find any useful information in the docs. I'm afraid I'm missing something obvious.


        Issue Links


          This comment will be Viewable by All Users Viewable by All Users


            tibordigana Tibor Digana
            kleewan Marco Patavini
            0 Vote for this issue
            3 Start watching this issue




                Issue deployment