test: improve backend branch coverage (currently 46%) #148

Closed
opened 2026-03-28 18:05:08 +01:00 by marcel · 0 comments
Owner

Summary

The JaCoCo branch coverage gate added in #120 is set to 42% minimum. Current measured coverage is 46% — only 4 percentage points of headroom. This issue tracks improving test coverage in the weakest areas.

Current coverage by package (last mvnw verify run)

Package Branches covered %
security 11 / 14 78%
service 241 / 478 50% ⚠️
controller 13 / 50 26%
repository 0 / 24 0%
Overall 265 / 566 46%

Priority areas

repository — 0% (0/24 branches)

Zero coverage. The @DataJpaTest tests added in #119 cover DocumentRepository and PersonRepository, but these 24 repository branches likely come from custom JPQL/derived query methods that need assertion-level tests, not just happy-path saves.

controller — 26% (13/50 branches)

Controllers have many if-blocks for permission checks, null guards, and error paths. These are not covered by unit tests and would benefit from @WebMvcTest slice tests or MockMvc integration tests.

service — 50% (241/478 branches)

The largest package. Many error branches in DocumentService, MassImportService, and UserService are untested. Consider targeted unit tests with mocked repositories for error paths.

Gate

The current minimum is 42%. Any PR that drops coverage below this will fail mvnw verify. Aim to raise the gate as coverage improves — suggested milestones: 50% → 60% → 70%.

## Summary The JaCoCo branch coverage gate added in #120 is set to **42%** minimum. Current measured coverage is **46%** — only 4 percentage points of headroom. This issue tracks improving test coverage in the weakest areas. ## Current coverage by package (last `mvnw verify` run) | Package | Branches covered | % | |---|---|---| | `security` | 11 / 14 | **78%** ✅ | | `service` | 241 / 478 | **50%** ⚠️ | | `controller` | 13 / 50 | **26%** ❌ | | `repository` | 0 / 24 | **0%** ❌ | | **Overall** | **265 / 566** | **46%** | ## Priority areas ### `repository` — 0% (0/24 branches) Zero coverage. The `@DataJpaTest` tests added in #119 cover `DocumentRepository` and `PersonRepository`, but these 24 repository branches likely come from custom JPQL/derived query methods that need assertion-level tests, not just happy-path saves. ### `controller` — 26% (13/50 branches) Controllers have many `if`-blocks for permission checks, null guards, and error paths. These are not covered by unit tests and would benefit from `@WebMvcTest` slice tests or MockMvc integration tests. ### `service` — 50% (241/478 branches) The largest package. Many error branches in `DocumentService`, `MassImportService`, and `UserService` are untested. Consider targeted unit tests with mocked repositories for error paths. ## Gate The current minimum is 42%. Any PR that drops coverage below this will fail `mvnw verify`. Aim to raise the gate as coverage improves — suggested milestones: 50% → 60% → 70%.
marcel added the test label 2026-03-28 18:05:19 +01:00
Sign in to join this conversation.
No Label test
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#148