Test coverage guide
Choose tests that demonstrate the changed behavior and catch regressions. Coverage helps locate untested code; a high percentage alone does not establish correctness.
Choose the test boundary
Unit tests
Test one behavior with small, deterministic fixtures. Cover normal results, invalid input, boundary conditions and failure handling. Use mocks for dependencies outside the test boundary, without asserting incidental implementation details. Follow the module's existing JUnit and Mockito conventions.
Integration tests
Exercise real interactions with databases, registries or other middleware where mocks cannot validate the behavior. Follow the relevant module and CI configuration for services, versions and opt-in flags. State prerequisites in the PR so another contributor can reproduce the result.
Compatibility and system tests
For protocol, serialization or transaction changes, identify the supported client/server combinations and test the affected paths, including failures and recovery. State which combinations were tested and which remain unverified.
Make tests repeatable
- Keep test classes under the relevant module's test source tree and follow its naming conventions.
- Isolate ports, database records and container resources between parallel tests.
- Clean up resources even when assertions fail.
- Prefer bounded condition checks to arbitrary sleeps; fix time and randomness when relevant.
- For a bug fix, show that the regression test fails before the fix and passes afterward.
Run and report
Use the checked-out revision's build instructions and JDK requirements. The current development instructions are in BUILDING.md.
./mvnw -version
./mvnw clean test
The JDK can change which modules are included. Tests requiring external services may need additional configuration. A passing default build is not evidence that every integration or compatibility test ran.
Interpret coverage
Inspect the coverage report for the PR's current commit. Explain uncovered changed branches and add meaningful assertions where needed. The target branch's configuration and required checks determine the enforced threshold; this guide does not impose a separate fixed percentage.
In the PR, record the commit, JDK, command, relevant services, result and any skipped checks. See the PR review guide for presenting verification limits.