Skip to content

test(android): Use fewer Robolectric SDK levels in core and replay - #6544

Merged
romtsn merged 2 commits into
mainfrom
romtsn/robolectric-ci-1-sdk-levels
Nov 11, 2026
Merged

romtsn merged 2 commits into
mainfrom
romtsn/robolectric-ci-1-sdk-levels

Conversation

@romtsn

@romtsn romtsn commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Moves pinned Robolectric SDK levels in sentry-android-core and sentry-android-replay tests to a smaller set of shared levels. Each test still takes the same code branch. The levels go from 11 to 6: 21, 24, 28, 30, 33 and 35.

From To Why it is the same branch
25 (N_MR1) 24 (N) The check is <= N_MR1
23 (M) 24 (N) The real SDK_INT checks on these paths are >= M and < O. The other checks use a mocked BuildInfoProvider
26 (O) 30 These tests need >= O. Between 26 and 30, the code under test has no branch that changes what they assert
31 (S), 34 33 (TIRAMISU) The code has no SDK check at 32 or 34. The S tests need >= S, and the "below API 35" tests need < VANILLA_ICE_CREAM

Level 28 stays: ReplaySmokeTest times out at 30, and AndroidConnectionStatusProviderTest gets a different network state at 30. One test name changes from "on API 23" to "on API 24".

💡 Motivation and Context

Robolectric makes a new sandbox for each SDK level that a test JVM uses, and the first use of a level is expensive. A trivial test at a new level takes ~1.3s locally, and the same test at a level that is already loaded takes ~0.01s. Each level also needs one android-all jar (100-200 MB), which Robolectric downloads at test runtime on CI.

💚 How did you test it?

All core and replay unit tests pass (2187 tests).

CI benchmark: a temporary workflow (not part of this PR) ran only :sentry-android-core:testReleaseUnitTest + :sentry-android-replay:testReleaseUnitTest. Each job ran main and this PR in turns on the same runner, so the runner hardware does not affect the comparison. Warm jars, 3 rounds per job:

Runner core: main → this PR replay: main → this PR
AMD EPYC 7763 179s / 179s / 176s → 152s / 153s / 150s 96s / 97s / 96s → 89s / 90s / 87s
Intel Xeon 8370C 180s / 180s / 180s → 149s / 150s / 152s 99s / 100s / 102s → 89s / 89s / 89s

So core is about 28s (16%) faster and replay about 10s (10%) faster. Locally (1 fork, 3 rounds), core went from 80-85s to 71s and replay from 47-48s to 45-46s.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

  • The other Robolectric modules (navigation, navigation3, distribution) could get the same change.
  • New tests should use one of the existing levels. A new level costs one more sandbox and one more jar download.

🤖 Generated with Claude Code

#skip-changelog

romtsn and others added 2 commits November 10, 2026 17:29
Robolectric starts a new sandbox for each SDK level a test JVM uses, and downloads one android-all jar per level. Move pinned levels to the nearest shared level that takes the same code branch: 23/25 -> 24, 26 -> 30, 31/34 -> 33. Level 28 stays because ReplaySmokeTest and AndroidConnectionStatusProviderTest behave differently at 30.

Core and replay now use 6 levels instead of 11. Locally, core Robolectric tests go from about 82s to 71s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sentry

sentry Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

@romtsn romtsn changed the title test(android): [Robolectric CI 1] Use fewer Robolectric SDK levels in core and replay test(android): Use fewer Robolectric SDK levels in core and replay Nov 11, 2026
@romtsn
romtsn changed the base branch from romtsn/robolectric-ci to main November 11, 2026 12:49
@romtsn
romtsn marked this pull request as ready for review November 11, 2026 12:50
@romtsn
romtsn requested review from a team and adinauer as code owners November 11, 2026 12:50
@romtsn
romtsn requested review from 0xadam-brown and runningcode and removed request for a team November 11, 2026 12:50
@romtsn
romtsn enabled auto-merge (squash) November 11, 2026 12:51
@romtsn romtsn closed this Nov 11, 2026
auto-merge was automatically disabled November 11, 2026 13:53

Pull request was closed

@romtsn romtsn reopened this Nov 11, 2026
@romtsn
romtsn enabled auto-merge (squash) November 11, 2026 13:53
@romtsn
romtsn merged commit 94f84ca into main Nov 11, 2026
65 of 68 checks passed
@romtsn
romtsn deleted the romtsn/robolectric-ci-1-sdk-levels branch November 11, 2026 14:14
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.

2 participants