AbstractTestLog.logln() doesn't do anything

Description

Here’s the implementation of AbstractTestLog.logln():

public static final void logln(String message) { // TODO(stuartg): turned off - causing OOM running under ant // Probably temporary - must decide what to do with these //System.out.println(message); //msg(message, LOG, true, true); }

In fact, all of the methods in this class are commented out, or don’t do any logging. The msg() method is commented out altogether, and the enums it takes as input don’t seem to exist. System.out.println() definitely seems like the wrong thing to be doing for logging, but the alternative can’t be to just do nothing.

The warn() and err() methods both just call Assert.fail(), so there’s no difference between a warning and an error, and Assert.fail() means if a test method tests more than one thing, it stops at the first failure (a problem I think all of the regular JUnit assertion methods also have).

There’s got to be some real logging framework we can tap into here for unit tests, doesn’t there? Doesn’t JUnit have something we can use? Moving to Maven seems like it gets us around the OOM problem mentioned in the comments above, but it also means all the System.out.println() calls go straight to the console, which also isn’t ideal.

Activity

Show:

Markus Scherer 
October 19, 2023 at 4:53 PM

Discussion: Move to use a logger. Consider https://www.slf4j.org/index.html “Simple Logging Facade for Java (SLF4J)“

Markus Scherer 
October 5, 2023 at 4:59 PM

Elango: In the Java world, we should use a logger and set it to the desired verbosity.

Yoshito: Stuart turned these off partly due to getting OOM. Yoshito doesn’t see that when reenabling some of this logging.

Markus Scherer 
September 14, 2023 at 5:01 PM

Discussion:

  • JUnit 4 seems to not have a concept of logging messages.

  • Consider printing to System.out (not to System.err because .out and .err can get out of order)

Details

Assignee

Reporter

Components

Priority

Time Needed

Hours

Fix versions

Created September 9, 2023 at 12:49 AM
Updated October 19, 2023 at 4:54 PM