Testing
Running Tests
Surefire runs all classes matching **/*Test.* and **/*Spec.*.
Test Framework
- JUnit 5 — Test runner
- Micronaut Test — Application context injection
- Micronaut HTTP Client — Controller testing
Test Class Pattern
Test Isolation
Each test class uses an in-memory H2 database to avoid collisions:
The DB_CLOSE_DELAY=-1 parameter keeps the database alive for the test duration.
HTTP Client Patterns
Use retrieve() over exchange().getBody()
Error Response Testing
Test Categories
Diagnostic Tests
When a test fails with an opaque error, create a minimal diagnostic test:
Clean up diagnostic test files after use.