System.out.print doesn't output to console when running from Junit

There are many ways people run JUnit tests (from within an IDE, from within a build system like Maven, or from a command line that uses the JUnit library directly). It appears that the way that you're running it uses a standard output that doesn't flush on every output. (This is probably intentional, as often tests are run in a batch using a continuous integration system, and the logs reviewed afterward, so not flushing on every write can improve performance.)

But, if you need to flush the buffer explicitly, try using System.out.flush(); after each .print call.

Another option, depending on what you're actually looking to do, may be to use a more full-featured logging system than the built-in System.out stream.


Ctrl + Shift + p and type show test output. Alternatively you can open the output window (Ctrl + J) and choose to see Test Output from a combo box on it's right upper corner.