test(compose): Robolectric JVM tests — onboarding & lock screens (batch 2/9) #377

Closed
opened 2026-07-06 20:07:09 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-06 20:07:09 +00:00 (Migrated from github.com)

Convert the stateless onboarding + lock screens to Robolectric JVM Compose tests and drop them from jacocoNonJvmTestableSurface.

Files (globs): OnboardingWelcomeScreen* (incl. WelcomeContent), LicenseScreen*, LockScreen*, ContactsAccessScreen*, BatteryOptimizationScreen*

Notes: Welcome/License/Lock are stateless callback-driven — trivial. ContactsAccessScreen/BatteryOptimizationScreen take an OnboardingViewModel; prefer testing the stateless ContactsAccessContent, and for the VM wrappers pass a fake/real OnboardingViewModel exposing the needed StateFlows. Mirror LicenseScreenTest, LockScreenTest, ContactsAccessStepTest, BatteryOptimizationStepTest. OnboardingWelcomeScreen fires NotificationPermissionEffect (a permission launcher) — drive WelcomeContent directly to avoid it, as its instrumented test does.

Recommended dispatch order: 2/9.


Part of the Robolectric Compose umbrella #373. Infra + PoC landed in PR #375 (Robolectric 4.16.1, testOptions.unitTests.isIncludeAndroidResources=true, src/test/resources/robolectric.properties pins sdk=36, v2 androidx.compose.ui.test.junit4.v2.createComposeRule).

Pattern to follow: app/src/test/kotlin/org/libremail/ui/onboarding/AddAnotherAccountScreenJvmTest.kt — @RunWith(RobolectricTestRunner) + @GraphicsMode(GraphicsMode.Mode.NATIVE) + @Config(sdk = [36]), v2 createComposeRule(), in the test (JVM) source set — NOT androidTest.

Acceptance criteria

  • Robolectric JVM Compose tests for each file below, covering its render + interaction/branch logic.
  • Remove the matching **/<File>* glob(s) from jacocoNonJvmTestableSurface in app/build.gradle.kts as each file gains genuine JVM coverage.
  • Keep the existing instrumented androidTest test(s) — the instrumented E2E stays.
  • Do NOT raise the JaCoCo floor (jacocoLineCoverageFloor, currently 0.79) — the re-ratchet is the final #373 step.
  • Fast gate green: assembleDebug + testDebugUnitTest + jacocoTestCoverageVerification + compileDebugAndroidTestKotlin + lintDebug + ktlintCheck + detekt.
Convert the stateless onboarding + lock screens to Robolectric JVM Compose tests and drop them from `jacocoNonJvmTestableSurface`. **Files (globs):** `OnboardingWelcomeScreen*` (incl. `WelcomeContent`), `LicenseScreen*`, `LockScreen*`, `ContactsAccessScreen*`, `BatteryOptimizationScreen*` **Notes:** Welcome/License/Lock are stateless callback-driven — trivial. `ContactsAccessScreen`/`BatteryOptimizationScreen` take an `OnboardingViewModel`; prefer testing the stateless `ContactsAccessContent`, and for the VM wrappers pass a fake/real `OnboardingViewModel` exposing the needed `StateFlow`s. Mirror LicenseScreenTest, LockScreenTest, ContactsAccessStepTest, BatteryOptimizationStepTest. `OnboardingWelcomeScreen` fires `NotificationPermissionEffect` (a permission launcher) — drive `WelcomeContent` directly to avoid it, as its instrumented test does. Recommended dispatch order: **2/9**. --- Part of the Robolectric Compose umbrella #373. Infra + PoC landed in PR #375 (Robolectric 4.16.1, `testOptions.unitTests.isIncludeAndroidResources=true`, `src/test/resources/robolectric.properties` pins `sdk=36`, v2 `androidx.compose.ui.test.junit4.v2.createComposeRule`). **Pattern to follow:** `app/src/test/kotlin/org/libremail/ui/onboarding/AddAnotherAccountScreenJvmTest.kt` — `@RunWith(RobolectricTestRunner)` + `@GraphicsMode(GraphicsMode.Mode.NATIVE)` + `@Config(sdk = [36])`, v2 `createComposeRule()`, in the **`test`** (JVM) source set — NOT `androidTest`. **Acceptance criteria** - Robolectric JVM Compose tests for each file below, covering its render + interaction/branch logic. - Remove the matching `**/<File>*` glob(s) from `jacocoNonJvmTestableSurface` in `app/build.gradle.kts` as each file gains genuine JVM coverage. - Keep the existing instrumented `androidTest` test(s) — the instrumented E2E stays. - **Do NOT raise the JaCoCo floor** (`jacocoLineCoverageFloor`, currently 0.79) — the re-ratchet is the final #373 step. - Fast gate green: `assembleDebug` + `testDebugUnitTest` + `jacocoTestCoverageVerification` + `compileDebugAndroidTestKotlin` + `lintDebug` + `ktlintCheck` + `detekt`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#377