From bd2566b6167dc18a9e76721735f10a78197afaab Mon Sep 17 00:00:00 2001 From: Stefano Date: Fri, 12 Sep 2025 15:47:41 +0200 Subject: [PATCH 1/2] updated changelog --- .../io/sentry/uitest/android/SdkInitTests.kt | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt b/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt index 07c9cd391a3..d9a2152565b 100644 --- a/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt +++ b/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt @@ -112,21 +112,12 @@ class SdkInitTests : BaseUiTest() { @Test fun doubleInitDoesNotWait() { - relayIdlingResource.increment() - // Let's make the first request timeout - relay.addTimeoutResponse() - - initSentry(true) { options: SentryAndroidOptions -> options.tracesSampleRate = 1.0 } - - Sentry.startTransaction("beforeRestart", "emptyTransaction").finish() + initSentry() // We want the SDK to start sending the event. If we don't wait, it's possible we don't send // anything before the SDK is restarted waitUntilIdle() - relayIdlingResource.increment() - relayIdlingResource.increment() - val beforeRestart = System.currentTimeMillis() // We restart the SDK. This shouldn't block the main thread, but new options (e.g. profiling) // should work @@ -137,27 +128,9 @@ class SdkInitTests : BaseUiTest() { val afterRestart = System.currentTimeMillis() val restartMs = afterRestart - beforeRestart - Sentry.startTransaction("afterRestart", "emptyTransaction").finish() // We assert for less than 1 second just to account for slow devices in saucelabs or headless // emulator assertTrue(restartMs < 1000, "Expected less than 1000 ms for SDK restart. Got $restartMs ms") - - relay.assert { - findEnvelope { assertEnvelopeTransaction(it.items.toList()).transaction == "beforeRestart" } - .assert { - it.assertTransaction() - // No profiling item, as in the first init it was not enabled - it.assertNoOtherItems() - } - findEnvelope { assertEnvelopeTransaction(it.items.toList()).transaction == "afterRestart" } - .assert { - it.assertTransaction() - // There is a profiling item, as in the second init it was enabled - it.assertProfile() - it.assertNoOtherItems() - } - assertNoOtherEnvelopes() - } } @Test From 59d386654c2c34d92806dc6c682b2b97930a60ea Mon Sep 17 00:00:00 2001 From: Stefano Date: Fri, 12 Sep 2025 17:05:59 +0200 Subject: [PATCH 2/2] updated test to check for new options --- .../io/sentry/uitest/android/SdkInitTests.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt b/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt index d9a2152565b..d3a60d2c198 100644 --- a/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt +++ b/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/SdkInitTests.kt @@ -112,11 +112,7 @@ class SdkInitTests : BaseUiTest() { @Test fun doubleInitDoesNotWait() { - initSentry() - - // We want the SDK to start sending the event. If we don't wait, it's possible we don't send - // anything before the SDK is restarted - waitUntilIdle() + initSentry(true) val beforeRestart = System.currentTimeMillis() // We restart the SDK. This shouldn't block the main thread, but new options (e.g. profiling) @@ -128,9 +124,23 @@ class SdkInitTests : BaseUiTest() { val afterRestart = System.currentTimeMillis() val restartMs = afterRestart - beforeRestart + relayIdlingResource.increment() + Sentry.startTransaction("afterRestart", "emptyTransaction").finish() + // We assert for less than 1 second just to account for slow devices in saucelabs or headless // emulator assertTrue(restartMs < 1000, "Expected less than 1000 ms for SDK restart. Got $restartMs ms") + + relay.assert { + findEnvelope { assertEnvelopeTransaction(it.items.toList()).transaction == "afterRestart" } + .assert { + it.assertTransaction() + // There is a profiling item, as in the second init it was enabled + it.assertProfile() + it.assertNoOtherItems() + } + assertNoOtherEnvelopes() + } } @Test