Gradle not displaying standard output when running junit tests, where the output of tested class in class static initializer block

Gradle is not displaying standard output (log4j nor System.out.println()) when running Java JUnit tests, where the output of the tested class is in the class static initializer block.

Finally, I can answer myself: The reason is that if you run a single test on the tested class, then the static initializer block will run. If you run a whole batch of JUnit tests, where the tested class is used (loaded) before, then the static block will run only once and in that previous test. If you need to run the static block again, you have to reload that tested class, or reset any properties that you are changing in that static block.