@@ -84,7 +84,7 @@ class RunTestTest {
84
84
85
85
/* * Tests that too low of a dispatch timeout causes crashes. */
86
86
@Test
87
- @Ignore // TODO: timeout leads to `Cannot execute task because event loop was shut down` on Native
87
+ @NoNative // TODO: timeout leads to `Cannot execute task because event loop was shut down` on Native
88
88
fun testRunTestWithSmallTimeout () = testResultMap({ fn ->
89
89
assertFailsWith<UncompletedCoroutinesError > { fn() }
90
90
}) {
@@ -107,7 +107,7 @@ class RunTestTest {
107
107
108
108
/* * Tests uncaught exceptions taking priority over dispatch timeout in error reports. */
109
109
@Test
110
- @Ignore // TODO: timeout leads to `Cannot execute task because event loop was shut down` on Native
110
+ @NoNative // TODO: timeout leads to `Cannot execute task because event loop was shut down` on Native
111
111
fun testRunTestTimingOutAndThrowing () = testResultMap({ fn ->
112
112
assertFailsWith<IllegalArgumentException > { fn() }
113
113
}) {
@@ -174,12 +174,12 @@ class RunTestTest {
174
174
175
175
/* * Tests that, once the test body has thrown, the child coroutines are cancelled. */
176
176
@Test
177
- fun testChildrenCancellationOnTestBodyFailure () {
177
+ fun testChildrenCancellationOnTestBodyFailure (): TestResult {
178
178
var job: Job ? = null
179
- testResultMap({
179
+ return testResultMap({
180
180
assertFailsWith<AssertionError > { it() }
181
181
assertTrue(job!! .isCancelled)
182
- }, {
182
+ }) {
183
183
runTest {
184
184
job = launch {
185
185
while (true ) {
@@ -188,34 +188,34 @@ class RunTestTest {
188
188
}
189
189
throw AssertionError ()
190
190
}
191
- })
191
+ }
192
192
}
193
193
194
194
/* * Tests that [runTest] reports [TimeoutCancellationException]. */
195
195
@Test
196
196
fun testTimeout () = testResultMap({
197
197
assertFailsWith<TimeoutCancellationException > { it() }
198
- }, {
198
+ }) {
199
199
runTest {
200
200
withTimeout(50 ) {
201
201
launch {
202
202
delay(1000 )
203
203
}
204
204
}
205
205
}
206
- })
206
+ }
207
207
208
208
/* * Checks that [runTest] throws the root cause and not [JobCancellationException] when a child coroutine throws. */
209
209
@Test
210
210
fun testRunTestThrowsRootCause () = testResultMap({
211
211
assertFailsWith<TestException > { it() }
212
- }, {
212
+ }) {
213
213
runTest {
214
214
launch {
215
215
throw TestException ()
216
216
}
217
217
}
218
- })
218
+ }
219
219
220
220
/* * Tests that [runTest] completes its job. */
221
221
@Test
@@ -224,13 +224,13 @@ class RunTestTest {
224
224
return testResultMap({
225
225
it()
226
226
assertTrue(handlerCalled)
227
- }, {
227
+ }) {
228
228
runTest {
229
229
coroutineContext.job.invokeOnCompletion {
230
230
handlerCalled = true
231
231
}
232
232
}
233
- })
233
+ }
234
234
}
235
235
236
236
/* * Tests that [runTest] doesn't complete the job that was passed to it as an argument. */
@@ -245,11 +245,11 @@ class RunTestTest {
245
245
it()
246
246
assertFalse(handlerCalled)
247
247
assertEquals(0 , job.children.filter { it.isActive }.count())
248
- }, {
248
+ }) {
249
249
runTest(job) {
250
250
assertTrue(coroutineContext.job in job.children)
251
251
}
252
- })
252
+ }
253
253
}
254
254
255
255
/* * Tests that, when the test body fails, the reported exceptions are suppressed. */
@@ -267,14 +267,14 @@ class RunTestTest {
267
267
assertEquals(" y" , suppressed[1 ].message)
268
268
assertEquals(" z" , suppressed[2 ].message)
269
269
}
270
- }, {
270
+ }) {
271
271
runTest {
272
272
launch(SupervisorJob ()) { throw TestException (" x" ) }
273
273
launch(SupervisorJob ()) { throw TestException (" y" ) }
274
274
launch(SupervisorJob ()) { throw TestException (" z" ) }
275
275
throw TestException (" w" )
276
276
}
277
- })
277
+ }
278
278
279
279
/* * Tests that [TestCoroutineScope.runTest] does not inherit the exception handler and works. */
280
280
@Test
@@ -287,10 +287,10 @@ class RunTestTest {
287
287
} catch (e: TestException ) {
288
288
scope.cleanupTestCoroutines() // should not fail
289
289
}
290
- }, {
290
+ }) {
291
291
scope.runTest {
292
292
launch(SupervisorJob ()) { throw TestException (" x" ) }
293
293
}
294
- })
294
+ }
295
295
}
296
296
}
0 commit comments