Skip to content

Commit 9970709

Browse files
committed
Return TestResult from Main dispatcher tests
1 parent 39a4af7 commit 9970709

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kotlinx-coroutines-core/common/test/MainDispatcherTestBase.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ abstract class MainDispatcherTestBase: TestBase() {
1515
open fun checkNotMainThread() {}
1616

1717
/** Runs the given block as a test, unless [shouldSkipTesting] indicates that the environment is not suitable. */
18-
fun runTestOrSkip(block: suspend CoroutineScope.() -> Unit) {
19-
if (shouldSkipTesting()) return
20-
runTest(block = block)
18+
fun runTestOrSkip(block: suspend CoroutineScope.() -> Unit): TestResult {
19+
// written as a block body to make the need to return `TestResult` explicit
20+
return runTest {
21+
if (shouldSkipTesting()) return@runTest
22+
block()
23+
}
2124
}
2225

2326
/** Tests the [toString] behavior of [Dispatchers.Main] and [MainCoroutineDispatcher.immediate] */

0 commit comments

Comments
 (0)