Skip to content

Commit 35aa581

Browse files
committed
Don't lose reported exceptions if the test body has thrown
1 parent 15ff917 commit 35aa581

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kotlinx-coroutines-test/common/src/TestBuilders.kt

+7
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ public fun runTest(
231231
}
232232
}
233233
deferred.getCompletionExceptionOrNull()?.let {
234+
try {
235+
testScope.cleanupTestCoroutines()
236+
} catch (e: UncompletedCoroutinesError) {
237+
// it's normal that some jobs are not completed if the test body has failed, won't clutter the output
238+
} catch (e: Throwable) {
239+
e.printStackTrace()
240+
}
234241
throw it
235242
}
236243
testScope.cleanupTestCoroutines()

0 commit comments

Comments
 (0)