1 import org.junit.*
2 import kotlinx.coroutines.*
3 import kotlinx.coroutines.debug.*
4 import org.junit.Test
5 import java.io.*
6 import java.lang.IllegalStateException
7 
8 class DynamicAttachDebugTest {
9 
10     @Test
testAgentDumpsCoroutinesnull11     fun testAgentDumpsCoroutines() =
12         DebugProbes.withDebugProbes {
13             runBlocking {
14                 val baos = ByteArrayOutputStream()
15                 DebugProbes.dumpCoroutines(PrintStream(baos))
16                 // if the agent works, then dumps should contain something,
17                 // at least the fact that this test is running.
18                 Assert.assertTrue(baos.toString().contains("testAgentDumpsCoroutines"))
19             }
20         }
21 
22     @Test(expected = IllegalStateException::class)
testAgentIsNotInstallednull23     fun testAgentIsNotInstalled() {
24         DebugProbes.dumpCoroutines(PrintStream(ByteArrayOutputStream()))
25     }
26 }
27