test(coverage): raise unit coverage past the 50% gate (phases 0-2)
All checks were successful
PR Checks / android-build (pull_request) Successful in 7m19s
All checks were successful
PR Checks / android-build (pull_request) Successful in 7m19s
Executes COVERAGE_PLAN.md phases 0-2 to clear the SonarQube new-code coverage gate (was 16.4%, threshold 50%). Estimated new-code coverage after this change is ~57%. 109 new tests across 19 files; full suite is 264 tests, all green. Phase 0 — coverage exclusions (sonar-project.properties): drop code a JVM unit test can't execute from the *coverage* denominator (still analysed for bugs/smells) — pure-@Composable UI the `*Screen.kt` glob missed (ui/components/**, BlockRenderer, ShardComponents), Android-framework glue (push services, Keystore-backed Encrypted* stores, Hilt di/**). Phase 1 — DTO serialization tests: AdminDto, PublicDto, WikiDto, PostDto/PageDto/ ContactDto, SsoDto, the shard board DTOs and player game-data DTOs, and the mobile-auth request bodies — decode + encode + computed helpers (isPublished/isMaintenance/ActorDto.label/ShardStatusDto.isOnline). Phase 2 — ViewModel tests: a MainDispatcherRule harness + hand-written API fakes (FakePublicApi/FakeAdminApi/FakePlayerShardApi/FakeShardStream) drive real repositories into the ViewModels. Covers the admin (dashboard/content/moderation/ support), content (news/post/page/wiki/home/contact), player (characters/ vendors/character/my-houses) and shard-board (champs/guilds/governors/houses/ hub) ViewModels — load success/error, form validation, role/status-aware feedback, and live-frame merging. To make the shard boards testable, extract a small `ShardStream` interface from `ShardStreamClient` (bound in NetworkModule) so `ShardRepository` depends on the capability, not the OkHttp client — lets a fake stream replace the perpetual SSE reconnect loop in tests. No production behaviour change. Phases 3 (repositories) and 4 (core net/auth top-up) are follow-ups; the deep-dependency auth family (Login/Account/TrustedDevices ViewModels, AuthRepository) lands with them. See docs/android/COVERAGE_PLAN.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgyHnrNa8WwG3doxvxjuCr
This commit is contained in:
@@ -26,16 +26,30 @@ sonar.sourceEncoding=UTF-8
|
||||
# coverage even though the JVM unit suite (app/src/test) exists.
|
||||
sonar.coverage.jacoco.xmlReportPaths=app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
|
||||
|
||||
# Exclude from *coverage* (not from analysis): pure-@Composable UI can't be exercised
|
||||
# by JVM unit tests without Robolectric, so counting those lines would unfairly sink
|
||||
# new-code coverage. Logic (ViewModels, repositories, core, DTOs) stays measured.
|
||||
# Exclude from *coverage* (not from analysis — bugs/smells are still reported): code a
|
||||
# JVM unit test physically can't execute, so counting its lines would unfairly sink
|
||||
# new-code coverage. Two kinds: pure-@Composable UI (needs Robolectric/instrumented
|
||||
# tests), and Android-framework glue (Keystore-backed stores, foreground push service,
|
||||
# notifications, Hilt modules). Testable logic — ViewModels, repositories, DTOs, and
|
||||
# pure core/ code — stays measured. See docs/android/COVERAGE_PLAN.md §1.
|
||||
sonar.coverage.exclusions=\
|
||||
app/src/main/java/**/ui/**/*Screen.kt,\
|
||||
app/src/main/java/**/ui/**/*Screen*.kt,\
|
||||
app/src/main/java/**/ui/theme/**,\
|
||||
app/src/main/java/**/ui/components/**,\
|
||||
app/src/main/java/**/ui/page/BlockRenderer.kt,\
|
||||
app/src/main/java/**/ui/shard/ShardComponents.kt,\
|
||||
app/src/main/java/**/ui/LocalAssetResolver.kt,\
|
||||
app/src/main/java/**/RunicApp.kt,\
|
||||
app/src/main/java/**/MainActivity.kt,\
|
||||
app/src/main/java/**/*Application.kt
|
||||
app/src/main/java/**/*Application.kt,\
|
||||
app/src/main/java/**/RunicGatewayApp.kt,\
|
||||
app/src/main/java/**/di/**,\
|
||||
app/src/main/java/**/core/push/PushService.kt,\
|
||||
app/src/main/java/**/core/push/PushManager.kt,\
|
||||
app/src/main/java/**/core/push/PushNotifier.kt,\
|
||||
app/src/main/java/**/core/push/NtfyStreamClient.kt,\
|
||||
app/src/main/java/**/core/auth/Encrypted*.kt
|
||||
|
||||
# ── Optional enrichment (enable once produced in CI) ──
|
||||
# • Android Lint: ./gradlew lintDebug → app/build/reports/lint-results-debug.xml
|
||||
|
||||
Reference in New Issue
Block a user