1 /* 2 * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 import kotlinx.coroutines.* 6 import kotlinx.coroutines.debug.junit4.* 7 import org.junit.* 8 9 @Ignore // do not run it on CI 10 class TestRuleExample { 11 12 @JvmField 13 @Rule 14 public val timeout = CoroutinesTimeout.seconds(1) 15 someFunctionDeepInTheStacknull16 private suspend fun someFunctionDeepInTheStack() { 17 withContext(Dispatchers.IO) { 18 delay(Long.MAX_VALUE) 19 println("This line is never executed") 20 } 21 22 println("This line is never executed as well") 23 } 24 25 @Test <lambda>null26 fun hangingTest() = runBlocking { 27 val job = launch { 28 someFunctionDeepInTheStack() 29 } 30 31 println("Doing some work...") 32 job.join() 33 } 34 35 @Test <lambda>null36 fun successfulTest() = runBlocking { 37 launch { 38 delay(10) 39 }.join() 40 } 41 42 } 43