Skip to content

Commit 01d4125

Browse files
committed
Rewrote CoroutineExceptionHandlerTest without CountDownLatch
1 parent 5667bcf commit 01d4125

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/CoroutineExceptionHandlerTest.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
package kotlinx.coroutines.experimental
22

33
import org.junit.Test
4-
import java.util.concurrent.CountDownLatch
5-
import java.util.concurrent.TimeUnit
64

7-
class CoroutineExceptionHandlerTest {
5+
class CoroutineExceptionHandlerTest : TestBase() {
86
@Test
9-
fun testCoroutineExceptionHandlerCreator() {
10-
val latch = CountDownLatch(1)
7+
fun testCoroutineExceptionHandlerCreator() = runBlocking {
8+
expect(1)
119
var coroutineException: Throwable? = null
12-
1310
val handler = CoroutineExceptionHandler { _, ex ->
1411
coroutineException = ex
15-
latch.countDown()
12+
expect(3)
1613
}
17-
18-
launch(CommonPool + handler) {
14+
val job = launch(CommonPool + handler) {
1915
throw TestException()
2016
}
21-
22-
latch.await(10, TimeUnit.SECONDS)
23-
17+
expect(2)
18+
job.join()
19+
finish(4)
2420
check(coroutineException is TestException)
2521
}
2622
}

0 commit comments

Comments
 (0)