Skip to content

I'm getting an error while installing #110

@MucahitZengin

Description

@MucahitZengin

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);
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions