Skip to content

Commit 985c3b1

Browse files
committed
Fix flaky EmbraceAnrServiceTimingTest.kt
1 parent f88a7b3 commit 985c3b1

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/anr/EmbraceAnrServiceTimingTest.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,15 @@ internal class EmbraceAnrServiceTimingTest {
8383
// Monitoring is initially started (even in background)
8484
assertTrue(state.started.get())
8585

86-
// Advance time by 9 seconds - monitoring should still be active
87-
anrExecutorService.moveForwardAndRunBlocked(TimeUnit.SECONDS.toMillis(9))
88-
assertTrue(state.started.get())
89-
90-
// Advance time by 2 more second to trigger the 10-second delayed check
91-
anrExecutorService.moveForwardAndRunBlocked(TimeUnit.SECONDS.toMillis(1))
86+
// Advance time by 20 seconds - this should trigger the delayed background check
87+
anrExecutorService.moveForwardAndRunBlocked(TimeUnit.SECONDS.toMillis(20))
9288

9389
// Run any pending tasks to ensure the delayed check executes
9490
anrExecutorService.runCurrentlyBlocked()
9591

92+
// Wait a bit to ensure the background check has time to run
93+
Thread.sleep(200L)
94+
9695
// Verify that monitoring is now stopped because app is still in background
9796
assertFalse(state.started.get())
9897
}

0 commit comments

Comments
 (0)