Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions kotlinx-coroutines-test/common/src/TestBuilders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public expect class TestResult
* // 2
* job.join() // the main test coroutine suspends here, so the child is executed
* // 4
* // use the results here
* }
*
* @Test
Expand All @@ -80,9 +81,32 @@ public expect class TestResult
* // 2
* testScheduler.advanceUntilIdle() // runs the tasks until their queue is empty
* // 4
* // use the results here
* }
* ```
*
*
* If the results of children coroutines computations are not needed in the runTest scope,
* there is no need to wait for children coroutines to finish, they are awaited for automatically
* by runTest parent coroutine.
* ```
* @Test
* fun exampleWaitingForAsyncTasks3() = runTest {
* val x = 0
* val y = 1
* // 1
* launch {
* // 3
* assertEquals(0, x)
* }
* launch {
* // 4
* assertEquals(1, y)
* }
* // 2
* } // 5
* ```
*
* ### Task scheduling
*
* Delay skipping is achieved by using virtual time.
Expand Down