Skip to content

Commit 7b67c20

Browse files
adinauerclaude
andauthored
fix(test): Fix flaky background-foreground replay test (#5140)
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 <noreply@anthropic.com>
1 parent bcd5eb7 commit 7b67c20

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sentry-android-core/src/test/java/io/sentry/android/core/LifecycleWatcherTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ class LifecycleWatcherTest {
282282
@Test
283283
fun `background-foreground replay`() {
284284
whenever(fixture.dateProvider.currentTimeMillis).thenReturn(1L)
285-
val watcher = fixture.getSUT(sessionIntervalMillis = 2L, enableAppLifecycleBreadcrumbs = false)
285+
val watcher =
286+
fixture.getSUT(sessionIntervalMillis = 500L, enableAppLifecycleBreadcrumbs = false)
286287
watcher.onForeground()
287288
verify(fixture.replayController).start()
288289

0 commit comments

Comments
 (0)