Skip to content

Commit

Permalink
runTestWithLogging coroutineScope 제거 및 onFailure 활용
Browse files Browse the repository at this point in the history
  • Loading branch information
kez-lab committed Jun 5, 2024
1 parent 0c9d1af commit 4b4a527
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
}

0 comments on commit 4b4a527

Please sign in to comment.