Skip to content

Commit

Permalink
Fix ANRv2 test flakyness (#3798)
Browse files Browse the repository at this point in the history
* try to fix ANRv2 test flakyness

* try to fix ANRv2 test flakyness
  • Loading branch information
stefanosiano authored Oct 16, 2024
1 parent 94071da commit bd82483
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.app.ApplicationExitInfo
import android.content.Context
import android.os.Build
import android.os.Bundle
import android.os.Looper
import android.os.SystemClock
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -55,6 +56,7 @@ import org.mockito.kotlin.spy
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.robolectric.Shadows
import org.robolectric.annotation.Config
import org.robolectric.shadow.api.Shadow
import org.robolectric.shadows.ShadowActivityManager
Expand Down Expand Up @@ -439,8 +441,10 @@ class SentryAndroidTest {
await.withAlias("Failed because of BeforeSend callback above, but we swallow BeforeSend exceptions, hence the timeout")
.untilTrue(asserted)

// Execute all posted tasks
Shadows.shadowOf(Looper.getMainLooper()).idle()

// assert that persisted values have changed
options.executorService.close(10000L) // finalizes all enqueued persisting tasks
assertEquals(
"TestActivity",
PersistingScopeObserver.read(options, TRANSACTION_FILENAME, String::class.java)
Expand Down

0 comments on commit bd82483

Please sign in to comment.