|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +This is the Java Testing Toolbox - a comprehensive educational repository demonstrating 30 testing tools and libraries for Java developers. The codebase contains practical examples for the book "30 Testing Tools & Libraries Every Java Developer Must Know". |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +### Module Structure |
| 12 | +- **spring-boot-example**: Main module containing most testing examples. Each testing tool has its own package under `src/test/java/de/rieckpil/blog/` |
| 13 | +- **jakarta-ee-example**: Demonstrates testing in Jakarta EE context, primarily MicroShed Testing |
| 14 | + |
| 15 | +### Test Organization |
| 16 | +- Unit tests: `*Test.java` or `*Spec.groovy` |
| 17 | +- Integration tests: `*IT.java` |
| 18 | +- Web tests: `*WT.java` |
| 19 | +- Performance tests: Located in `gatling` package |
| 20 | +- All test examples are self-contained within their respective packages |
| 21 | + |
| 22 | +## Essential Commands |
| 23 | + |
| 24 | +### Spring Boot Example |
| 25 | + |
| 26 | +```bash |
| 27 | +# Build and run all tests |
| 28 | +./mvnw verify |
| 29 | + |
| 30 | +# Run unit tests only |
| 31 | +./mvnw test |
| 32 | + |
| 33 | +# Run integration tests only |
| 34 | +./mvnw failsafe:integration-test |
| 35 | + |
| 36 | +# Run specific test class |
| 37 | +./mvnw test -Dtest=UserRegistrationServiceTest |
| 38 | + |
| 39 | +# Start the application (requires Docker) |
| 40 | +docker-compose up -d |
| 41 | +./mvnw spring-boot:run |
| 42 | + |
| 43 | +# Run Gatling performance tests (requires running application) |
| 44 | +./mvnw gatling:test |
| 45 | + |
| 46 | +# Run mutation testing |
| 47 | +./mvnw pitest:mutationCoverage |
| 48 | + |
| 49 | +# Generate JGiven reports |
| 50 | +./mvnw jgiven:report |
| 51 | + |
| 52 | +# Run Pact consumer tests |
| 53 | +./mvnw test -Dtest=StockApiContractTest |
| 54 | + |
| 55 | +# Publish pacts to broker (requires running Pact Broker) |
| 56 | +docker-compose -f docker-pact-broker-compose.yml up -d |
| 57 | +./mvnw pact:publish |
| 58 | + |
| 59 | +# Run Pact provider verification tests (by default skipped with system property) |
| 60 | +./mvnw test -Dtest=StockApiProviderTest |
| 61 | +``` |
| 62 | + |
| 63 | +### Jakarta EE Example |
| 64 | + |
| 65 | +```bash |
| 66 | +# Build and run all tests |
| 67 | +./mvnw verify |
| 68 | + |
| 69 | +# Run unit tests only |
| 70 | +./mvnw test |
| 71 | + |
| 72 | +# Run integration tests |
| 73 | +./mvnw failsafe:integration-test |
| 74 | + |
| 75 | +# Start Liberty server |
| 76 | +./mvnw liberty:run |
| 77 | +``` |
| 78 | + |
| 79 | +## Key Testing Patterns |
| 80 | + |
| 81 | +### Test Infrastructure |
| 82 | + |
| 83 | +- **Testcontainers**: Used extensively for integration tests requiring databases or external services |
| 84 | +- **Docker Compose**: Provides PostgreSQL and other services for local development |
| 85 | +- **MockWebServer/WireMock**: For mocking external HTTP services |
| 86 | +- **LocalStack**: For testing AWS services locally |
| 87 | + |
| 88 | +### Testing Frameworks Coverage |
| 89 | + |
| 90 | +The repository demonstrates these testing categories: |
| 91 | + |
| 92 | +1. Test Runners: JUnit 4/5, TestNG, Spock |
| 93 | +2. Assertions: AssertJ, Hamcrest, JsonPath, XMLUnit, JSONAssert |
| 94 | +3. Mocking: Mockito, WireMock, MockWebServer |
| 95 | +4. Integration: Testcontainers, REST Assured, MicroShed Testing |
| 96 | +5. Web Testing: Selenium, Selenide |
| 97 | +6. Performance: Gatling, JMH, JfrUnit |
| 98 | +7. Contract Testing: Pact |
| 99 | +8. Architecture Testing: ArchUnit |
| 100 | + |
| 101 | +### Important Conventions |
| 102 | + |
| 103 | +- Java 21 is required for all modules |
| 104 | +- Docker must be running for integration tests |
| 105 | +- Test output is redirected to files in CI/CD environments |
| 106 | +- Each testing tool example is isolated in its own package |
| 107 | +- Examples demonstrate real-world usage patterns, not just basic syntax |
0 commit comments