diff --git a/runtime-attach/runtime-attach/build.gradle.kts b/runtime-attach/runtime-attach/build.gradle.kts index b0bc63065..15cb3361a 100644 --- a/runtime-attach/runtime-attach/build.gradle.kts +++ b/runtime-attach/runtime-attach/build.gradle.kts @@ -24,6 +24,48 @@ dependencies { testImplementation("org.assertj:assertj-core") } +testing { + suites { + val test by getting(JvmTestSuite::class) { + targets.all { + testTask.configure { + setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class + filter { + excludeTestsMatching("AgentDisabledByEnvironmentVariableTest") + excludeTestsMatching("AgentDisabledBySystemPropertyTest") + } + } + } + } + + val testAgentDisabledByEnvironmentVariable by registering(JvmTestSuite::class) { + targets.all { + testTask.configure { + setForkEvery(1) + filter { + includeTestsMatching("AgentDisabledByEnvironmentVariableTest") + } + include("**/AgentDisabledByEnvironmentVariableTest.*") + environment("OTEL_JAVAAGENT_ENABLED", "false") + } + } + } + + val testAgentDisabledBySystemProperty by registering(JvmTestSuite::class) { + targets.all { + testTask.configure { + setForkEvery(1) + filter { + includeTestsMatching("AgentDisabledBySystemPropertyTest") + } + include("**/AgentDisabledBySystemPropertyTest.*") + jvmArgs("-Dotel.javaagent.enabled=false") + } + } + } + } +} + tasks { jar { inputs.files(agent) @@ -32,31 +74,4 @@ tasks { }) rename("^(.*)\\.jar\$", "otel-agent.jar") } - - withType().configureEach { - setForkEvery(1) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class - } - - val testAgentDisabledByEnvironmentVariable by registering(Test::class) { - filter { - includeTestsMatching("AgentDisabledByEnvironmentVariableTest") - } - include("**/AgentDisabledByEnvironmentVariableTest.*") - environment("OTEL_JAVAAGENT_ENABLED", "false") - } - - val testAgentDisabledBySystemProperty by registering(Test::class) { - filter { - includeTestsMatching("AgentDisabledBySystemPropertyTest") - } - include("**/AgentDisabledBySystemPropertyTest.*") - jvmArgs("-Dotel.javaagent.enabled=false") - } - - test { - filter { - excludeTestsMatching("AgentDisabledByEnvironmentVariableTest") - excludeTestsMatching("AgentDisabledBySystemPropertyTest") - } - } }