This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
AssertLog is a Java library for unit-testing logging. It intercepts log output during tests and provides assertion methods to verify what was (or was not) logged.
Group ID: com.codeborne.assertlog | Current version: 0.2-SNAPSHOT
./gradlew test # run all tests (default task also runs clean)
./gradlew clean test # clean build then test (what CI runs)
./gradlew :assertlog-log4j-junit4:test --tests "org.assertlog.PetClinicTest#info" # single test
./gradlew build # compile + test + jarTests only run classes matching org/assertlog/**/* (configured in root build.gradle).
Two submodules declared in settings.gradle:
assertlog-core— shared types only; currently justOriginalLogsPolicyenum (SHOW/HIDE)assertlog-log4j-junit4— Log4j 1.x + JUnit 4 integration; depends onassertlog-core
Each submodule has its own build.gradle for dependencies. Root build.gradle applies shared config (Java 8 source/target, UTF-8 encoding, test logging). gradle/deploy.gradle handles Maven Central publishing via uploadArchives (requires signing.keyId property).
MockLogging (assertlog-log4j-junit4) is a JUnit 4 ExternalResource rule that:
before()— saves the root Log4j logger's state, sets the configured log level, removes existing appenders ifpolicy == HIDE, then adds a capturing appender that feeds into an internalArrayDeque<LoggingEvent>after()— removes the capturing appender and restores the original level and appenders
Assertion methods consume events from the queue (ordered, dequeue semantics) except:
assertLoggedInAnyOrder/assertLogged(Pattern)/assertNotLogged(Pattern)— search without requiring orderassertNoMoreLogs()— fails if the queue is not empty (typically called in@After)
assertNotLogged and assertLogged(Pattern) (the non-consuming overload) must be called before the dequeue-based assertLogged methods, as the queue is mutated.
The pattern for a new logging framework or test runner is:
- Create a new submodule (e.g.,
assertlog-logback-junit5) - Add it to
settings.gradle - Implement an equivalent of
MockLoggingusing the target framework's extension mechanism - Depend on
assertlog-corefor shared types