From 4b4a5277e2cbff7cf90225429b0ca840d347ce7f Mon Sep 17 00:00:00 2001 From: KwakEuiJin Date: Wed, 5 Jun 2024 20:54:57 +0900 Subject: [PATCH] =?UTF-8?q?runTestWithLogging=20coroutineScope=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20=EB=B0=8F=20onFailure=20=ED=99=9C=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/testing/coroutines/runTestWithLogging.kt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/core/testing/src/main/java/com/droidknights/app/core/testing/coroutines/runTestWithLogging.kt b/core/testing/src/main/java/com/droidknights/app/core/testing/coroutines/runTestWithLogging.kt index f3234ead..49b61e24 100644 --- a/core/testing/src/main/java/com/droidknights/app/core/testing/coroutines/runTestWithLogging.kt +++ b/core/testing/src/main/java/com/droidknights/app/core/testing/coroutines/runTestWithLogging.kt @@ -1,6 +1,5 @@ package com.droidknights.app.core.testing.coroutines -import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runTest import kotlin.coroutines.CoroutineContext @@ -14,15 +13,9 @@ fun runTestWithLogging( testBody: suspend TestScope.() -> Unit, ) = runTest(context, timeout) { runCatching { - coroutineScope { - testBody() - } - }.let { - if (it.isFailure) { - it.exceptionOrNull()?.let { exception -> - exception.printStackTrace() - throw exception - } - } + testBody() + }.onFailure { exception -> + exception.printStackTrace() + throw exception } }