Skip to content

Commit

Permalink
Don't lose reported exceptions if the test body has thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb committed Oct 25, 2021
1 parent f2d4ce1 commit ae524a7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kotlinx-coroutines-test/common/src/TestBuilders.kt
Expand Up @@ -231,6 +231,13 @@ public fun runTest(
}
}
deferred.getCompletionExceptionOrNull()?.let {
try {
testScope.cleanupTestCoroutines()
} catch (e: UncompletedCoroutinesError) {
// it's normal that some jobs are not completed if the test body has failed, won't clutter the output
} catch (e: Throwable) {
e.printStackTrace()
}
throw it
}
testScope.cleanupTestCoroutines()
Expand Down

0 comments on commit ae524a7

Please sign in to comment.