@@ -24,6 +24,48 @@ dependencies {
2424 testImplementation(" org.assertj:assertj-core" )
2525}
2626
27+ testing {
28+ suites {
29+ val test by getting(JvmTestSuite ::class ) {
30+ targets.all {
31+ testTask.configure {
32+ setForkEvery(1 ) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
33+ filter {
34+ excludeTestsMatching(" AgentDisabledByEnvironmentVariableTest" )
35+ excludeTestsMatching(" AgentDisabledBySystemPropertyTest" )
36+ }
37+ }
38+ }
39+ }
40+
41+ val testAgentDisabledByEnvironmentVariable by registering(JvmTestSuite ::class ) {
42+ targets.all {
43+ testTask.configure {
44+ setForkEvery(1 )
45+ filter {
46+ includeTestsMatching(" AgentDisabledByEnvironmentVariableTest" )
47+ }
48+ include(" **/AgentDisabledByEnvironmentVariableTest.*" )
49+ environment(" OTEL_JAVAAGENT_ENABLED" , " false" )
50+ }
51+ }
52+ }
53+
54+ val testAgentDisabledBySystemProperty by registering(JvmTestSuite ::class ) {
55+ targets.all {
56+ testTask.configure {
57+ setForkEvery(1 )
58+ filter {
59+ includeTestsMatching(" AgentDisabledBySystemPropertyTest" )
60+ }
61+ include(" **/AgentDisabledBySystemPropertyTest.*" )
62+ jvmArgs(" -Dotel.javaagent.enabled=false" )
63+ }
64+ }
65+ }
66+ }
67+ }
68+
2769tasks {
2870 jar {
2971 inputs.files(agent)
@@ -32,31 +74,4 @@ tasks {
3274 })
3375 rename(" ^(.*)\\ .jar\$ " , " otel-agent.jar" )
3476 }
35-
36- withType<Test >().configureEach {
37- setForkEvery(1 ) // One JVM by test class to avoid a test class launching a runtime attachment influences the behavior of another test class
38- }
39-
40- val testAgentDisabledByEnvironmentVariable by registering(Test ::class ) {
41- filter {
42- includeTestsMatching(" AgentDisabledByEnvironmentVariableTest" )
43- }
44- include(" **/AgentDisabledByEnvironmentVariableTest.*" )
45- environment(" OTEL_JAVAAGENT_ENABLED" , " false" )
46- }
47-
48- val testAgentDisabledBySystemProperty by registering(Test ::class ) {
49- filter {
50- includeTestsMatching(" AgentDisabledBySystemPropertyTest" )
51- }
52- include(" **/AgentDisabledBySystemPropertyTest.*" )
53- jvmArgs(" -Dotel.javaagent.enabled=false" )
54- }
55-
56- test {
57- filter {
58- excludeTestsMatching(" AgentDisabledByEnvironmentVariableTest" )
59- excludeTestsMatching(" AgentDisabledBySystemPropertyTest" )
60- }
61- }
6277}
0 commit comments