Skip to content

Commit be8c2b9

Browse files
committed
Fixes
1 parent e6b1453 commit be8c2b9

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

kotlinx-coroutines-test/MIGRATION.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ was called.
1717

1818
We currently don't provide a replacement for this.
1919
However, `runTest` follows structured concurrency better than `runBlockingTest` did, so exceptions from child coroutines
20-
are propagated structurally in more cases than before, which makes uncaught exception handlers less useful.
20+
are propagated structurally, which makes uncaught exception handlers less useful.
2121

2222
If you have a use case for this, please tell us about it at the issue tracker.
2323
Meanwhile, it should be possible to use a custom exception captor, which should only implement
@@ -78,12 +78,13 @@ It is already illegal to use a `TestCoroutineScope` without performing `cleanupT
7878
An example is shown below.
7979

8080
```kotlin
81+
val exceptions = mutableListOf<Throwable>()
82+
val customCaptor = CoroutineExceptionHandler { ctx, throwable ->
83+
exceptions.add(throwable) // add proper synchronization if the test is multithreaded
84+
}
85+
8186
@Test
8287
fun testFoo() = runTest {
83-
val exceptions = mutableListOf<Throwable>()
84-
val customCaptor = CoroutineExceptionHandler { ctx, throwable ->
85-
exceptions.add(throwable) // add proper synchronization if the test is multithreaded
86-
}
8788
launch(customCaptor) {
8889
// ...
8990
}

kotlinx-coroutines-test/README.md

-7
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ on Kotlin/JS. The main differences are the following:
111111
guide the execution, advancing the virtual time by a duration, draining the queue of the awaiting tasks, or running
112112
the tasks scheduled at the present moment.
113113
* **Handling uncaught exceptions** spawned in the child coroutines by throwing them at the end of the test.
114-
* **Detecting unfinished jobs**, that is, tasks that are still pending by the end of the test, in order to prevent
115-
coroutine leaks.
116114
* **Waiting for asynchronous callbacks**.
117115
Sometimes, especially when working with third-party code, it's impossible to mock all the dispatchers in use.
118116
[runTest] will handle the situations where some code runs in dispatchers not integrated with the test module.
@@ -318,11 +316,6 @@ fun testEagerlyEnteringSomeChildCoroutines() = runTest(UnconfinedTestDispatcher(
318316
}
319317
```
320318

321-
## Detecting unfinished jobs
322-
323-
The test framework ensures that coroutines are not leaked.
324-
To this end, the coroutines that aren't finished by the end of the test are reported.
325-
326319
### Using `withTimeout` inside `runTest`
327320

328321
Timeouts are also susceptible to time control, so the code below will immediately finish.

0 commit comments

Comments
 (0)