1 /* 2 * Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 import org.junit.* 5 import kotlinx.coroutines.* 6 import kotlinx.coroutines.debug.* 7 import org.junit.Test 8 import java.io.* 9 import java.lang.IllegalStateException 10 11 class DynamicAttachDebugTest { 12 13 @Test testAgentDumpsCoroutinesnull14 fun testAgentDumpsCoroutines() = 15 DebugProbes.withDebugProbes { 16 runBlocking { 17 val baos = ByteArrayOutputStream() 18 DebugProbes.dumpCoroutines(PrintStream(baos)) 19 // if the agent works, then dumps should contain something, 20 // at least the fact that this test is running. 21 Assert.assertTrue(baos.toString().contains("testAgentDumpsCoroutines")) 22 } 23 } 24 25 @Test(expected = IllegalStateException::class) testAgentIsNotInstallednull26 fun testAgentIsNotInstalled() { 27 DebugProbes.dumpCoroutines(PrintStream(ByteArrayOutputStream())) 28 } 29 } 30