Skip to content

Commit e76c4e5

Browse files
runningcodeclaude
andauthored
test(android): Collect UI test breadcrumbs in a thread-safe list (#6681)
beforeBreadcrumb runs on whichever thread adds the breadcrumb, so the Compose click and swipe tests could append to a plain ArrayList from two threads at once and fail with an NPE. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 639b370 commit e76c4e5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android

‎sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/UserInteractionTests.kt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import io.sentry.Breadcrumb
1515
import io.sentry.SentryLevel
1616
import io.sentry.SentryOptions
1717
import io.sentry.android.core.SentryAndroidOptions
18+
import java.util.concurrent.CopyOnWriteArrayList
1819
import kotlin.test.Test
1920
import kotlin.test.assertTrue
2021
import org.hamcrest.CoreMatchers.`is`
@@ -31,7 +32,8 @@ class UserInteractionTests : BaseUiTest() {
3132

3233
@Test
3334
fun composableClickGeneratesMatchingBreadcrumb() {
34-
val breadcrumbs = mutableListOf<Breadcrumb>()
35+
// beforeBreadcrumb runs on whichever thread adds the breadcrumb
36+
val breadcrumbs = CopyOnWriteArrayList<Breadcrumb>()
3537
initSentryAndCollectBreadcrumbs(breadcrumbs)
3638

3739
val activity = launchActivity<ComposeActivity>()
@@ -65,7 +67,8 @@ class UserInteractionTests : BaseUiTest() {
6567

6668
@Test
6769
fun composableSwipeGeneratesMatchingBreadcrumb() {
68-
val breadcrumbs = mutableListOf<Breadcrumb>()
70+
// beforeBreadcrumb runs on whichever thread adds the breadcrumb
71+
val breadcrumbs = CopyOnWriteArrayList<Breadcrumb>()
6972
initSentryAndCollectBreadcrumbs(breadcrumbs)
7073

7174
val activity = launchActivity<ComposeActivity>()

0 commit comments

Comments
 (0)