From f0d45f19002cd201bdfdad6dee6a0137bf3eb3a4 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Tue, 3 Mar 2026 06:19:15 +0100 Subject: [PATCH] fix(test): Fix flaky background-foreground replay test Increase sessionIntervalMillis from 2ms to 500ms so the timer task from the first onBackground() doesn't fire before cancelTask() in the second onForeground() can cancel it. With 2ms the timer could race and call replayController.stop() twice. Co-Authored-By: Claude --- .../test/java/io/sentry/android/core/LifecycleWatcherTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/LifecycleWatcherTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/LifecycleWatcherTest.kt index 5149f16712..09c4fae8dc 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/LifecycleWatcherTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/LifecycleWatcherTest.kt @@ -282,7 +282,8 @@ class LifecycleWatcherTest { @Test fun `background-foreground replay`() { whenever(fixture.dateProvider.currentTimeMillis).thenReturn(1L) - val watcher = fixture.getSUT(sessionIntervalMillis = 2L, enableAppLifecycleBreadcrumbs = false) + val watcher = + fixture.getSUT(sessionIntervalMillis = 500L, enableAppLifecycleBreadcrumbs = false) watcher.onForeground() verify(fixture.replayController).start()