@@ -87,7 +87,7 @@ public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineS
87
87
* * Don't nest functions returning a [TestResult].
88
88
*/
89
89
@Suppress(" NO_ACTUAL_FOR_EXPECT" )
90
- @DelicateCoroutinesApi
90
+ @ExperimentalCoroutinesApi
91
91
public expect class TestResult
92
92
93
93
/* *
@@ -159,7 +159,7 @@ public expect class TestResult
159
159
*
160
160
* In the general case, if there are active jobs, it's impossible to detect if they are going to complete eventually due
161
161
* to the asynchronous nature of coroutines. In order to prevent tests hanging in this scenario, [runTest] will wait
162
- * for [dispatchTimeoutMs] milliseconds (by default, 10 seconds) from the moment when [TestCoroutineScheduler] becomes
162
+ * for [dispatchTimeoutMs] milliseconds (by default, 60 seconds) from the moment when [TestCoroutineScheduler] becomes
163
163
* idle before throwing [AssertionError]. If some dispatcher linked to [TestCoroutineScheduler] receives a
164
164
* task during that time, the timer gets reset.
165
165
*
@@ -172,7 +172,7 @@ public expect class TestResult
172
172
* @throws IllegalArgumentException if the [context] is invalid. See the [TestCoroutineScope] constructor docs for
173
173
* details.
174
174
*/
175
- @DelicateCoroutinesApi
175
+ @ExperimentalCoroutinesApi
176
176
public fun runTest (
177
177
context : CoroutineContext = EmptyCoroutineContext ,
178
178
dispatchTimeoutMs : Long = DEFAULT_DISPATCH_TIMEOUT_MS ,
@@ -197,24 +197,21 @@ public fun runTest(
197
197
completed = true
198
198
continue
199
199
}
200
- try {
201
- withTimeout(dispatchTimeoutMs) {
202
- select<Unit > {
203
- testScope.onJoin {
204
- completed = true
205
- }
206
- scheduler.onDispatchEvent {
207
- // we received knowledge that `scheduler` observed a dispatch event, so we reset the timeout
208
- }
209
- }
200
+ select<Unit > {
201
+ testScope.onJoin {
202
+ completed = true
210
203
}
211
- } catch (e: TimeoutCancellationException ) {
212
- try {
213
- testScope.cleanupTestCoroutines()
214
- } catch (e: UncompletedCoroutinesError ) {
215
- // we expect these and will instead throw a more informative exception just below.
204
+ scheduler.onDispatchEvent {
205
+ // we received knowledge that `scheduler` observed a dispatch event, so we reset the timeout
206
+ }
207
+ onTimeout(dispatchTimeoutMs) {
208
+ try {
209
+ testScope.cleanupTestCoroutines()
210
+ } catch (e: UncompletedCoroutinesError ) {
211
+ // we expect these and will instead throw a more informative exception just below.
212
+ }
213
+ throw UncompletedCoroutinesError (" The test coroutine was not completed after waiting for $dispatchTimeoutMs ms" )
216
214
}
217
- throw UncompletedCoroutinesError (" The test coroutine was not completed after waiting for $dispatchTimeoutMs ms" )
218
215
}
219
216
}
220
217
testScope.getCompletionExceptionOrNull()?.let {
@@ -248,7 +245,7 @@ internal expect fun createTestResult(testProcedure: suspend () -> Unit): TestRes
248
245
* Since this function returns [TestResult], in order to work correctly on the JS, its result must be returned
249
246
* immediately from the test body. See the docs for [TestResult] for details.
250
247
*/
251
- @DelicateCoroutinesApi
248
+ @ExperimentalCoroutinesApi
252
249
public fun TestCoroutineScope.runTest (
253
250
dispatchTimeoutMs : Long = DEFAULT_DISPATCH_TIMEOUT_MS ,
254
251
block : suspend TestCoroutineScope .() -> Unit
@@ -263,7 +260,7 @@ public fun TestCoroutineScope.runTest(
263
260
* Since this function returns [TestResult], in order to work correctly on the JS, its result must be returned
264
261
* immediately from the test body. See the docs for [TestResult] for details.
265
262
*/
266
- @DelicateCoroutinesApi
263
+ @ExperimentalCoroutinesApi
267
264
public fun TestDispatcher.runTest (
268
265
dispatchTimeoutMs : Long = DEFAULT_DISPATCH_TIMEOUT_MS ,
269
266
block : suspend TestCoroutineScope .() -> Unit
@@ -280,7 +277,7 @@ private object RunningInRunTest: CoroutineContext.Key<RunningInRunTest>, Corouti
280
277
281
278
/* * The default timeout to use when waiting for asynchronous completions of the coroutines managed by
282
279
* a [TestCoroutineScheduler]. */
283
- private const val DEFAULT_DISPATCH_TIMEOUT_MS = 10_000L
280
+ private const val DEFAULT_DISPATCH_TIMEOUT_MS = 60_000L
284
281
285
282
private class TestBodyCoroutine <T >(
286
283
private val testScope : TestCoroutineScope ,
0 commit comments