|
| 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 Overview |
| 6 | + |
| 7 | +ApprovalTests.Java is a snapshot-based testing library that simplifies assertions by comparing expected output to approved files. The library supports JUnit 3/4/5 and TestNG, and works with JDK 1.8-25. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +This is a multi-module Maven project with the following key modules: |
| 12 | + |
| 13 | +- **approvaltests**: Main library containing core functionality (`Approvals.java`, writers, reporters, namers) |
| 14 | +- **approvaltests-util**: Shared utilities and helper classes |
| 15 | +- **approvaltests-tests**: Integration tests and examples |
| 16 | +- **approvaltests-util-tests**: Tests for utility classes |
| 17 | +- **counter_display**: Sample application |
| 18 | +- **html_locker**: Additional tooling |
| 19 | + |
| 20 | +The core API is in `org.approvaltests.Approvals` class, which provides static methods like `verify()`, `verifyAll()`, `verifyAsJson()`. The library uses a pattern of Writers (generate output), Namers (determine file names), and Reporters (show differences when tests fail). |
| 21 | + |
| 22 | +## Common Commands |
| 23 | + |
| 24 | +### Build and Test |
| 25 | +```bash |
| 26 | +# Full build with all tests |
| 27 | +mvn install |
| 28 | + |
| 29 | +# Build and test (recommended) |
| 30 | +./build_and_test.sh |
| 31 | + |
| 32 | +# Skip tests if some are machine/locale dependent |
| 33 | +mvn install -DskipTests |
| 34 | + |
| 35 | +# Run tests for specific module |
| 36 | +mvn verify -pl approvaltests-tests/ |
| 37 | +``` |
| 38 | + |
| 39 | +### Development |
| 40 | +```bash |
| 41 | +# Format code |
| 42 | +mvn formatter:format |
| 43 | + |
| 44 | +# Run just the main tests |
| 45 | +./run_tests_without_compile_dependencies.sh |
| 46 | +``` |
| 47 | + |
| 48 | +## Key Files and Concepts |
| 49 | + |
| 50 | +- **Approved files**: `*.approved.*` files must be committed to source control and treated as binary in git (add `*.approved.* binary` to `.gitattributes`) |
| 51 | +- **Received files**: Generated during test failures, showing actual output vs approved |
| 52 | +- **Reporters**: Tools that show diffs when tests fail (IntelliJ, Beyond Compare, etc.) |
| 53 | +- **Namers**: Determine approval file naming based on test method/class |
| 54 | +- **Writers**: Generate the actual content to be approved |
| 55 | + |
| 56 | +## Running Single Tests |
| 57 | + |
| 58 | +Individual test methods can be run using standard Maven/IDE approaches: |
| 59 | +```bash |
| 60 | +mvn test -Dtest=ClassName#methodName |
| 61 | +``` |
| 62 | + |
| 63 | +## Code Style |
| 64 | + |
| 65 | +The project uses the formatter plugin with configuration in `spun.xml`. Code formatting is enforced via Maven build. |
0 commit comments