Skip to content

Commit 2413511

Browse files
asolntsevclaude
andcommitted
add CLAUDE.md with build commands and architecture overview
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8197d76 commit 2413511

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.gradle
22
/.idea
33
/out
4-
build
4+
build
5+
/.claude/settings.local.json

CLAUDE.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project
6+
7+
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.
8+
9+
Group ID: `com.codeborne.assertlog` | Current version: `0.2-SNAPSHOT`
10+
11+
## Commands
12+
13+
```bash
14+
./gradlew test # run all tests (default task also runs clean)
15+
./gradlew clean test # clean build then test (what CI runs)
16+
./gradlew :assertlog-log4j-junit4:test --tests "org.assertlog.PetClinicTest#info" # single test
17+
./gradlew build # compile + test + jar
18+
```
19+
20+
Tests only run classes matching `org/assertlog/**/*` (configured in root `build.gradle`).
21+
22+
## Module Structure
23+
24+
Two submodules declared in `settings.gradle`:
25+
26+
- **`assertlog-core`** — shared types only; currently just `OriginalLogsPolicy` enum (`SHOW`/`HIDE`)
27+
- **`assertlog-log4j-junit4`** — Log4j 1.x + JUnit 4 integration; depends on `assertlog-core`
28+
29+
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).
30+
31+
## Key Class: MockLogging
32+
33+
`MockLogging` (`assertlog-log4j-junit4`) is a JUnit 4 `ExternalResource` rule that:
34+
35+
1. **`before()`** — saves the root Log4j logger's state, sets the configured log level, removes existing appenders if `policy == HIDE`, then adds a capturing appender that feeds into an internal `ArrayDeque<LoggingEvent>`
36+
2. **`after()`** — removes the capturing appender and restores the original level and appenders
37+
38+
Assertion methods consume events from the queue (ordered, dequeue semantics) except:
39+
- `assertLoggedInAnyOrder` / `assertLogged(Pattern)` / `assertNotLogged(Pattern)` — search without requiring order
40+
- `assertNoMoreLogs()` — fails if the queue is not empty (typically called in `@After`)
41+
42+
`assertNotLogged` and `assertLogged(Pattern)` (the non-consuming overload) **must be called before** the dequeue-based `assertLogged` methods, as the queue is mutated.
43+
44+
## Adding New Integrations
45+
46+
The pattern for a new logging framework or test runner is:
47+
1. Create a new submodule (e.g., `assertlog-logback-junit5`)
48+
2. Add it to `settings.gradle`
49+
3. Implement an equivalent of `MockLogging` using the target framework's extension mechanism
50+
4. Depend on `assertlog-core` for shared types

0 commit comments

Comments
 (0)