-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Description
When I try to install it with Maven, it gives the following error:
[ERROR] Failures:
[ERROR] NumberOfLogStatementsTest.testCountLog4JHelloWorldFile:31 expected: <7> but was: <6>
The 31st line mentioned is here:
28 @Test
29 public void testCountLog4JHelloWorldFile() {
30 CKClassResult a = report.get("logs.Log4JHelloWorld");
31 assertEquals(7, a.getNumberOfLogStatements());
32 }
The Log4JHelloWorld class is like this:
public class Log4JHelloWorld {
private static final Logger logger = LogManager.getLogger("HelloWorld");
public static void main(String[] args) {
logger.info("Hello, World!");
if (logger.isDebugEnabled()) {
logger.debug("Logging in user " + user.getName() + " with birthday " + user.getBirthdayCalendar());
}
logger.debug("Logging in user {} with birthday {}", user.getName(), user.getBirthdayCalendar());
// Java-8 style optimization: no need to explicitly check the log level:
// the lambda expression is not evaluated if the TRACE level is not enabled
logger.trace("Some long-running operation returned {}", () -> expensiveOperation());
// pre-Java 8 style optimization: explicitly check the log level
// to make sure the expensiveOperation() method is only called if necessary
if (logger.isTraceEnabled()) {
logger.trace("Some long-running operation returned {}", expensiveOperation());
}
// Fluent API/Builder Pattern
logger.atError().withThrowable(exception).log("Unable to process request due to {}", code);
logger.atInfo().withMarker(marker).withLocation().withThrowable(exception).log("Login for user {} failed", userId);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels