Lines Matching refs:TestCoroutineScope
235 …| [TestCoroutineScope] | A [CoroutineScope] which provides detailed control over the execution of …
240 a [TestCoroutineDispatcher] but not a [TestCoroutineScope].
242 [TestCoroutineScope] will always use a [TestCoroutineDispatcher] to execute coroutines. It
245 By providing [TestCoroutineScope] a test case is able to control execution of coroutines, as well a…
248 ### Providing `TestCoroutineScope` from `runBlockingTest`
250 In simple cases, tests can use the [TestCoroutineScope] created by [runBlockingTest] directly.
255 foo() // runBlockingTest passed in a TestCoroutineScope as this
259 launch { // CoroutineScope for launch is the TestCoroutineScope provided by runBlockingTest
267 ### Providing an explicit `TestCoroutineScope`
272 Tests can declare a [TestCoroutineScope] explicitly in the class to support these use cases.
274 Since [TestCoroutineScope] is stateful in order to keep track of executing coroutines and uncaught …
275 important to ensure that [cleanupTestCoroutines][TestCoroutineScope.cleanupTestCoroutines] is calle…
279 private val testScope = TestCoroutineScope()
295 …// TestCoroutineScope.runBlockingTest uses the Dispatcher and exception handler provided by `testS…
309 *Note:* [TestCoroutineScope], [TestCoroutineDispatcher], and [TestCoroutineExceptionHandler] are in…
311 [Dispatchers.setMain][setMain] then expose [TestCoroutineScope] for use in tests.
315 While providing a [TestCoroutineScope] is slightly preferred due to the improved uncaught exception…
317 does not accept a [TestCoroutineScope] and requires a [TestCoroutineDispatcher] to control coroutin…
320 The main difference between `TestCoroutineScope` and `TestCoroutineDispatcher` is how uncaught exce…
323 `TestCoroutineScope` will always use `TestCoroutineDispatcher` as it's dispatcher.
325 A test can use a `TestCoroutineDispatcher` without declaring an explicit `TestCoroutineScope`. This…
362 *Note:* Prefer to provide `TestCoroutineScope` when it does not complicate code since it will also …
366 ### Using `TestCoroutineScope` and `TestCoroutineDispatcher` without `runBlockingTest`
368 It is supported to use both [TestCoroutineScope] and [TestCoroutineDispatcher] without using the [r…
375 val scope = TestCoroutineScope()
384 println(1) // executes eagerly when foo() is called due to TestCoroutineScope
453 [TestCoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.c…
455 [TestCoroutineScope.cleanupTestCoroutines]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-cor…