When running:
public static void main(String... args) throws InterruptedException {
while (true) {
System.out.print(".");
Thread.sleep(200);
}
}
vs. when running same code from junit:
@Test
public void test() throws Exception {
while (true) {
System.out.print(".");
Thread.sleep(200);
}
}
There is different behaviour:
for the main() - the output is displayed as expected, as the process runs ("." -> ".." -> "...")
however, for JUnit, when running same piece of code, No output is displayed as the process runs - It's flushed only when quitting the test.
Why does this happen? Is there any way to workaround it if I need the status to be shown in console during the test run?
I need to print to the same line, so using println wouldn't suit.