Skip to content

Commit f0d45f1

Browse files
adinauerclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 9054d65 commit f0d45f1

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)