Skip to content

fix(test): update Robolectric SDK config from 23 to 26 - #244

Open
forkline-bot[bot] wants to merge 2 commits into
mainfrom
fix/ci-robolectric-sdk-config
Open

forkline-bot[bot] wants to merge 2 commits into
mainfrom
fix/ci-robolectric-sdk-config

Conversation

@forkline-bot

@forkline-bot forkline-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

Summary

Fixed CI failures in StrictDomainRegexTest (6 tests) and AutofillDecryptActivityTest caused by java.lang.IllegalArgumentException at UnknownSdk.java:45.

Root Cause

Robolectric 4.17 enforces that @Config(sdk) must be >= the app's minSdk. The app's minSdk is 26, but both test files were configured with @Config(sdk = [23]), which is no longer valid.

Changes

  • Updated StrictDomainRegexTest from @Config(sdk = [23]) to @Config(sdk = [26])
  • Updated AutofillDecryptActivityTest from @Config(sdk = [23]) to @Config(sdk = [26])

Both changes align the Robolectric SDK configuration with the app's minSdk = 26.


This PR was generated by Forkline — AI-powered code contributions.
The agent analyzed the issue and implemented this fix autonomously.

Robolectric 4.17 enforces that @config(sdk) must be >= app minSdk.
The app's minSdk is 26, so SDK 23 is no longer valid and causes
IllegalArgumentException at UnknownSdk.java:45.

Updated both StrictDomainRegexTest and AutofillDecryptActivityTest
to use @config(sdk = [26]) to match the app's minSdk.
- Remove @config(sdk=[26]) from AutofillDecryptActivityTest to let
  Robolectric use its default SDK selection (targetSdk clamped to max
  supported). This eliminates the root cause: hardcoded SDK pins break
  when minSdk changes.

- Remove Robolectric entirely from StrictDomainRegexTest since it tests
  pure Kotlin regex logic (generateStrictDomainRegex) with no Android
  dependencies. This makes the test faster and eliminates SDK coupling
  for 6 of 7 previously affected tests.

Both changes improve maintainability by removing brittle SDK
configuration that caused the original CI failures.
@forkline-bot

forkline-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown
Author

Maintainability Review

  • Initial expected implementation: matched
  • Initial reason: PR description says update @Config(sdk) from 23 to 26 in two test files; implementation did exactly that
  • Applied maintenance work: removed brittle SDK pins and unnecessary Robolectric dependency (see below)
  • Final implementation: matches — CI fix preserved, root cause eliminated
  • Validation: all 5 CI checks pass (unit-tests, passkey-tests, build-apks, lint, check-codestyle)

Findings

1. Priority: medium
Category: bug / test
Decision: applied
Location: StrictDomainRegexTest.kt
Problem: This test exercises generateStrictDomainRegex which is pure Kotlin Regex logic with zero Android API usage. Running it under Robolectric added ~seconds of JVM startup per test class and created the exact SDK coupling that caused the original CI failure. The test was migrated to Robolectric in 2021 when it was moved from androidTest to test, but Robolectric was never actually needed for the regex logic.
Action: Removed @RunWith(RobolectricTestRunner::class), @Config, and Robolectric imports. The test now runs as a plain JUnit test, consistent with many other tests in the project (e.g., ExternalSshSignatureTest, GitOperationCoordinatorTest, AutofillPasskeyExclusionTest).
Why it is worth it: Eliminates the root cause for 6 of 7 previously affected tests, makes the test faster, and removes a dependency that was never needed.
Risk / scope: Low. generateStrictDomainRegex uses only kotlin.text.Regex. The companion object has no static initializers referencing Android classes. CI confirms the test passes.

2. Priority: medium
Category: bug / refactor
Decision: applied
Location: AutofillDecryptActivityTest.kt
Problem: @Config(sdk = [26]) hardcodes the SDK to the current minSdk. The next minSdk bump will break this test with the same UnknownSdk error — the exact failure mode this PR is fixing. The test doesn't depend on any SDK-specific behavior; it tests Intent extras which are stable across SDK 26+.
Action: Removed the @Config(sdk = [26]) annotation. Robolectric now uses its default SDK selection (targetSdk clamped to max supported SDK, currently 36), which is always >= minSdk by construction. This eliminates the failure mode entirely.
Why it is worth it: Removes the brittle coupling between test config and minSdk. Future minSdk bumps will not break this test.
Risk / scope: Low. RuntimeEnvironment.getApplication(), Intent, and Bundle are stable APIs. CI confirms the test passes on Robolectric's default SDK.

3. Priority: low
Category: implementation gap
Decision: do not pursue
Location: build-logic/.../AndroidCommon.kt
Problem: compileSdk = 37 is hardcoded. The Android SDK Platform 37 is not yet available in the standard public repository (only android-36 is installed locally), which prevented local test validation.
Action: No change. This is outside the scope of this PR and the project's CI environment has android-37 available.
Why not pursue: Out of scope; no evidence this causes issues in CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants