1 import kotlinx.coroutines.* 2 import kotlinx.coroutines.debug.junit4.* 3 import org.junit.* 4 5 @Ignore // do not run it on CI 6 class TestRuleExample { 7 8 @JvmField 9 @Rule 10 public val timeout = CoroutinesTimeout.seconds(1) 11 someFunctionDeepInTheStacknull12 private suspend fun someFunctionDeepInTheStack() { 13 withContext(Dispatchers.IO) { 14 delay(Long.MAX_VALUE) 15 println("This line is never executed") 16 } 17 18 println("This line is never executed as well") 19 } 20 21 @Test <lambda>null22 fun hangingTest() = runBlocking { 23 val job = launch { 24 someFunctionDeepInTheStack() 25 } 26 27 println("Doing some work...") 28 job.join() 29 } 30 31 @Test <lambda>null32 fun successfulTest() = runBlocking { 33 launch { 34 delay(10) 35 }.join() 36 } 37 38 } 39