From 08fb1b5715fef4343d5bf5eeefab029cfc357eda Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 29 Oct 2024 11:29:27 +0000 Subject: [PATCH] test(ManualSessionSmokeScenario): moved the test onto a background thread to try and avoid ANRs --- .../scenarios/ManualSessionSmokeScenario.kt | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/ManualSessionSmokeScenario.kt b/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/ManualSessionSmokeScenario.kt index b9a50c3a61..c552d721b7 100644 --- a/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/ManualSessionSmokeScenario.kt +++ b/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/ManualSessionSmokeScenario.kt @@ -6,6 +6,7 @@ import com.bugsnag.android.Configuration import com.bugsnag.android.createDefaultDelivery import com.bugsnag.android.mazerunner.InterceptingDelivery import java.util.concurrent.CountDownLatch +import kotlin.concurrent.thread /** * Sends an exception after pausing the session @@ -27,23 +28,25 @@ internal class ManualSessionSmokeScenario( override fun startScenario() { super.startScenario() - Bugsnag.setUser("123", "ABC.CBA.CA", "ManualSessionSmokeScenario") + thread { + Bugsnag.setUser("123", "ABC.CBA.CA", "ManualSessionSmokeScenario") - // send session - Bugsnag.startSession() + // send session + Bugsnag.startSession() - // send exception with session - Bugsnag.notify(generateException()) + // send exception with session + Bugsnag.notify(generateException()) - // send exception without session - Bugsnag.pauseSession() - Bugsnag.notify(generateException()) + // send exception without session + Bugsnag.pauseSession() + Bugsnag.notify(generateException()) - // override to ensure request order, as the order of fatal errors - // can be indeterminate if they are persisted to disk at the same - // millisecond as another error. - deliveryLatch.await() - Bugsnag.resumeSession() - throw generateException() + // override to ensure request order, as the order of fatal errors + // can be indeterminate if they are persisted to disk at the same + // millisecond as another error. + deliveryLatch.await() + Bugsnag.resumeSession() + throw generateException() + } } }