Skip to content

Commit 94f84ca

Browse files
romtsnclaude
andauthored
test(android): Use fewer Robolectric SDK levels in core and replay (#6544)
* collection: Robolectric CI speed-up * test(android): Use fewer Robolectric SDK levels in core and replay 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> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 00a30a7 commit 94f84ca

14 files changed

Lines changed: 22 additions & 22 deletions

‎sentry-android-core/src/test/java/io/sentry/android/core/ActivityLifecycleIntegrationTest.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ class ActivityLifecycleIntegrationTest {
704704
}
705705

706706
@Test
707-
@Config(sdk = [Build.VERSION_CODES.M])
708-
fun `onHeadlessAppStart creates standalone App Start transaction on API 23`() {
707+
@Config(sdk = [Build.VERSION_CODES.N])
708+
fun `onHeadlessAppStart creates standalone App Start transaction on API 24`() {
709709
val sut = fixture.getSut {
710710
it.tracesSampleRate = 1.0
711711
it.isEnableStandaloneAppStartTracing = true

‎sentry-android-core/src/test/java/io/sentry/android/core/AndroidOptionsInitializerTest.kt‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,31 +375,31 @@ class AndroidOptionsInitializerTest {
375375
assertTrue(fixture.sentryOptions.transportGate is AndroidTransportGate)
376376
}
377377

378-
@Config(sdk = [Build.VERSION_CODES.N_MR1])
378+
@Config(sdk = [Build.VERSION_CODES.N])
379379
@Test
380380
fun `init on API 25 and lower sets SSLSocketFactory with bundled Sentry root CAs`() {
381381
fixture.initSut(configureOptions = { dsn = SAAS_DSN })
382382

383383
assertIs<SentryRootCaSslSocketFactory>(fixture.sentryOptions.sslSocketFactory)
384384
}
385385

386-
@Config(sdk = [Build.VERSION_CODES.N_MR1])
386+
@Config(sdk = [Build.VERSION_CODES.N])
387387
@Test
388388
fun `init on API 25 and lower does not set SSLSocketFactory for self-hosted DSN`() {
389389
fixture.initSut(configureOptions = { dsn = "https://key@sentry.example.com/1" })
390390

391391
assertNull(fixture.sentryOptions.sslSocketFactory)
392392
}
393393

394-
@Config(sdk = [Build.VERSION_CODES.O])
394+
@Config(sdk = [30])
395395
@Test
396396
fun `init on API 26 and higher does not set SSLSocketFactory`() {
397397
fixture.initSut(configureOptions = { dsn = SAAS_DSN })
398398

399399
assertNull(fixture.sentryOptions.sslSocketFactory)
400400
}
401401

402-
@Config(sdk = [Build.VERSION_CODES.N_MR1])
402+
@Config(sdk = [Build.VERSION_CODES.N])
403403
@Test
404404
fun `init on API 25 and lower keeps user provided SSLSocketFactory`() {
405405
val sslSocketFactory = mock<javax.net.ssl.SSLSocketFactory>()
@@ -442,7 +442,7 @@ class AndroidOptionsInitializerTest {
442442
)
443443
}
444444

445-
@Config(sdk = [34])
445+
@Config(sdk = [33])
446446
@Test
447447
fun `init below API 35 does not report PerfettoContinuousProfiling integration`() {
448448
SentryIntegrationPackageStorage.getInstance().clearStorage()
@@ -455,14 +455,14 @@ class AndroidOptionsInitializerTest {
455455
)
456456
}
457457

458-
@Config(sdk = [34])
458+
@Config(sdk = [33])
459459
@Test
460460
fun `init below API 35 with enableLegacyProfiling true sets AndroidContinuousProfiler`() {
461461
fixture.initSut(configureOptions = { isEnableLegacyProfiling = true })
462462
assertTrue(fixture.sentryOptions.continuousProfiler is AndroidContinuousProfiler)
463463
}
464464

465-
@Config(sdk = [34])
465+
@Config(sdk = [33])
466466
@Test
467467
fun `init below API 35 with enableLegacyProfiling false noops profiler`() {
468468
fixture.initSut(configureOptions = { isEnableLegacyProfiling = false })

‎sentry-android-core/src/test/java/io/sentry/android/core/ApplicationExitInfoCrossIntegrationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import org.robolectric.shadows.ShadowActivityManager.ApplicationExitInfoBuilder
3535
// Our current Robolectric version (4.15) caps at API 35. All ApplicationExitInfo code paths we
3636
// exercise are at API 31 or below, so we use the latter.
3737
@RunWith(AndroidJUnit4::class)
38-
@Config(sdk = [31])
38+
@Config(sdk = [33])
3939
class ApplicationExitInfoCrossIntegrationTest {
4040

4141
@get:Rule val tmpDir = TemporaryFolder()

‎sentry-android-core/src/test/java/io/sentry/android/core/ScreenshotEventProcessorTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ScreenshotEventProcessorTest {
202202
}
203203

204204
@Test
205-
@Config(sdk = [23])
205+
@Config(sdk = [24])
206206
fun `when screenshot event processor is called from background thread it executes on main thread`() {
207207
val sut = fixture.getSut(true)
208208
whenever(fixture.threadChecker.isMainThread).thenReturn(false)

‎sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class SentryAndroidTest {
350350
}
351351

352352
@Test
353-
@Config(sdk = [26])
353+
@Config(sdk = [30])
354354
fun `init starts session replay if app is in foreground`() {
355355
initSentryWithForegroundImportance(true) { _ ->
356356
Shadows.shadowOf(Looper.getMainLooper()).idle()
@@ -359,7 +359,7 @@ class SentryAndroidTest {
359359
}
360360

361361
@Test
362-
@Config(sdk = [26])
362+
@Config(sdk = [30])
363363
fun `init does not start session replay if the app is in background`() {
364364
initSentryWithForegroundImportance(false) { _ ->
365365
Shadows.shadowOf(Looper.getMainLooper()).idle()

‎sentry-android-core/src/test/java/io/sentry/android/core/SessionTrackingIntegrationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import org.junit.runner.RunWith
3636
import org.robolectric.annotation.Config
3737

3838
@RunWith(AndroidJUnit4::class)
39-
@Config(sdk = [31])
39+
@Config(sdk = [33])
4040
class SessionTrackingIntegrationTest {
4141
private lateinit var context: Context
4242

‎sentry-android-core/src/test/java/io/sentry/android/core/TombstoneIntegrationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.robolectric.annotation.Config
2626
import org.robolectric.shadows.ShadowActivityManager.ApplicationExitInfoBuilder
2727

2828
@RunWith(AndroidJUnit4::class)
29-
@Config(sdk = [31])
29+
@Config(sdk = [33])
3030
class TombstoneIntegrationTest : ApplicationExitIntegrationTestBase<TombstoneHint>() {
3131

3232
override val config =

‎sentry-android-core/src/test/java/io/sentry/android/core/internal/util/AndroidConnectionStatusProviderConcurrencyTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import org.robolectric.annotation.Config
6161
* that must not wait for them run on a separate caller thread with a bounded wait.
6262
*/
6363
@RunWith(AndroidJUnit4::class)
64-
@Config(sdk = [Build.VERSION_CODES.S])
64+
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
6565
class AndroidConnectionStatusProviderConcurrencyTest {
6666

6767
@AfterTest

‎sentry-android-core/src/test/java/io/sentry/android/core/internal/util/AndroidConnectionStatusProviderTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class AndroidConnectionStatusProviderTest {
258258

259259
/// Lets a test reject work only after the setup that needs a working executor is done.
260260
@Test
261-
@Config(sdk = [Build.VERSION_CODES.S])
261+
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
262262
fun `When the network callback cannot be registered, the telephony listener is not started`() {
263263
// Without ACCESS_NETWORK_STATE the network callback registration fails, and onBackground skips
264264
// unregistering while there is no network callback, so the listener must not be started here.

‎sentry-android-core/src/test/java/io/sentry/android/core/internal/util/CellularNetworkTechnologyProviderTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import org.mockito.kotlin.whenever
2727
import org.robolectric.annotation.Config
2828

2929
@RunWith(AndroidJUnit4::class)
30-
@Config(sdk = [Build.VERSION_CODES.S])
30+
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
3131
class CellularNetworkTechnologyProviderTest {
3232
private class Fixture {
3333
val context = mock<Context>()

0 commit comments

Comments
 (0)