-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TestNG tracing for parameterized tests that modify parameters
- Loading branch information
1 parent
9bf5bbd
commit 94d24cb
Showing
10 changed files
with
354 additions
and
29 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...on/testng/src/main/java/datadog/trace/instrumentation/testng/TestEventsHandlerHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...rumentation/testng/src/testFixtures/java/org/example/TestParameterizedModifiesParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.example; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
/** Inspired by a real-world example */ | ||
public class TestParameterizedModifiesParams { | ||
|
||
@DataProvider(name = "dataProvider") | ||
public static Object[][] data() { | ||
return new Object[][] {{"I will modify this set", new HashSet<>()}}; | ||
} | ||
|
||
@Test(dataProvider = "dataProvider") | ||
public void parameterized_test_succeed(final String str, final Set<String> set) { | ||
set.add("why not"); | ||
assertEquals(1, set.size()); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ation/testng/testng-6/src/test/resources/test-parameterized-modifies-params/coverages.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ ] |
157 changes: 157 additions & 0 deletions
157
...entation/testng/testng-6/src/test/resources/test-parameterized-modifies-params/events.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
[ { | ||
"type" : "test_suite_end", | ||
"version" : 1, | ||
"content" : { | ||
"test_session_id" : ${content_test_session_id}, | ||
"test_module_id" : ${content_test_module_id}, | ||
"test_suite_id" : ${content_test_suite_id}, | ||
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain", | ||
"name" : "testng.test_suite", | ||
"resource" : "org.example.TestParameterizedModifiesParams", | ||
"start" : ${content_start}, | ||
"duration" : ${content_duration}, | ||
"error" : 0, | ||
"metrics" : { }, | ||
"meta" : { | ||
"test.type" : "test", | ||
"os.architecture" : ${content_meta_os_architecture}, | ||
"test.source.file" : "dummy_source_path", | ||
"test.module" : "testng-6", | ||
"test.status" : "pass", | ||
"runtime.name" : ${content_meta_runtime_name}, | ||
"runtime.vendor" : ${content_meta_runtime_vendor}, | ||
"env" : "none", | ||
"os.platform" : ${content_meta_os_platform}, | ||
"dummy_ci_tag" : "dummy_ci_tag_value", | ||
"os.version" : ${content_meta_os_version}, | ||
"library_version" : ${content_meta_library_version}, | ||
"component" : "testng", | ||
"span.kind" : "test_suite_end", | ||
"test.suite" : "org.example.TestParameterizedModifiesParams", | ||
"runtime.version" : ${content_meta_runtime_version}, | ||
"test.framework_version" : ${content_meta_test_framework_version}, | ||
"test.framework" : "testng" | ||
} | ||
} | ||
}, { | ||
"type" : "test", | ||
"version" : 2, | ||
"content" : { | ||
"trace_id" : ${content_trace_id}, | ||
"span_id" : ${content_span_id}, | ||
"parent_id" : ${content_parent_id}, | ||
"test_session_id" : ${content_test_session_id}, | ||
"test_module_id" : ${content_test_module_id}, | ||
"test_suite_id" : ${content_test_suite_id}, | ||
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain", | ||
"name" : "testng.test", | ||
"resource" : "org.example.TestParameterizedModifiesParams.parameterized_test_succeed", | ||
"start" : ${content_start_2}, | ||
"duration" : ${content_duration_2}, | ||
"error" : 0, | ||
"metrics" : { | ||
"process_id" : ${content_metrics_process_id}, | ||
"_dd.profiling.enabled" : 0, | ||
"_dd.trace_span_attribute_schema" : 0, | ||
"test.source.end" : 18, | ||
"test.source.start" : 12 | ||
}, | ||
"meta" : { | ||
"os.architecture" : ${content_meta_os_architecture}, | ||
"test.source.file" : "dummy_source_path", | ||
"test.source.method" : "parameterized_test_succeed(Ljava/lang/String;Ljava/util/Set;)V", | ||
"test.module" : "testng-6", | ||
"test.status" : "pass", | ||
"language" : "jvm", | ||
"runtime.name" : ${content_meta_runtime_name}, | ||
"os.platform" : ${content_meta_os_platform}, | ||
"test.codeowners" : "[\"owner1\",\"owner2\"]", | ||
"os.version" : ${content_meta_os_version}, | ||
"library_version" : ${content_meta_library_version}, | ||
"test.name" : "parameterized_test_succeed", | ||
"span.kind" : "test", | ||
"test.suite" : "org.example.TestParameterizedModifiesParams", | ||
"runtime.version" : ${content_meta_runtime_version}, | ||
"runtime-id" : ${content_meta_runtime_id}, | ||
"test.type" : "test", | ||
"runtime.vendor" : ${content_meta_runtime_vendor}, | ||
"env" : "none", | ||
"dummy_ci_tag" : "dummy_ci_tag_value", | ||
"test.parameters" : "{\"arguments\":{\"0\":\"I will modify this set\",\"1\":\"[]\"}}", | ||
"component" : "testng", | ||
"_dd.profiling.ctx" : "test", | ||
"test.framework_version" : ${content_meta_test_framework_version}, | ||
"test.framework" : "testng" | ||
} | ||
} | ||
}, { | ||
"type" : "test_session_end", | ||
"version" : 1, | ||
"content" : { | ||
"test_session_id" : ${content_test_session_id}, | ||
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain", | ||
"name" : "testng.test_session", | ||
"resource" : "testng-6", | ||
"start" : ${content_start_3}, | ||
"duration" : ${content_duration_3}, | ||
"error" : 0, | ||
"metrics" : { | ||
"process_id" : ${content_metrics_process_id}, | ||
"_dd.profiling.enabled" : 0, | ||
"_dd.trace_span_attribute_schema" : 0 | ||
}, | ||
"meta" : { | ||
"test.type" : "test", | ||
"os.architecture" : ${content_meta_os_architecture}, | ||
"test.status" : "pass", | ||
"language" : "jvm", | ||
"runtime.name" : ${content_meta_runtime_name}, | ||
"runtime.vendor" : ${content_meta_runtime_vendor}, | ||
"env" : "none", | ||
"os.platform" : ${content_meta_os_platform}, | ||
"dummy_ci_tag" : "dummy_ci_tag_value", | ||
"os.version" : ${content_meta_os_version}, | ||
"library_version" : ${content_meta_library_version}, | ||
"component" : "testng", | ||
"_dd.profiling.ctx" : "test", | ||
"span.kind" : "test_session_end", | ||
"runtime.version" : ${content_meta_runtime_version}, | ||
"runtime-id" : ${content_meta_runtime_id}, | ||
"test.command" : "testng-6", | ||
"test.framework_version" : ${content_meta_test_framework_version}, | ||
"test.framework" : "testng" | ||
} | ||
} | ||
}, { | ||
"type" : "test_module_end", | ||
"version" : 1, | ||
"content" : { | ||
"test_session_id" : ${content_test_session_id}, | ||
"test_module_id" : ${content_test_module_id}, | ||
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain", | ||
"name" : "testng.test_module", | ||
"resource" : "testng-6", | ||
"start" : ${content_start_4}, | ||
"duration" : ${content_duration_4}, | ||
"error" : 0, | ||
"metrics" : { }, | ||
"meta" : { | ||
"test.type" : "test", | ||
"os.architecture" : ${content_meta_os_architecture}, | ||
"test.module" : "testng-6", | ||
"test.status" : "pass", | ||
"runtime.name" : ${content_meta_runtime_name}, | ||
"runtime.vendor" : ${content_meta_runtime_vendor}, | ||
"env" : "none", | ||
"os.platform" : ${content_meta_os_platform}, | ||
"dummy_ci_tag" : "dummy_ci_tag_value", | ||
"os.version" : ${content_meta_os_version}, | ||
"library_version" : ${content_meta_library_version}, | ||
"component" : "testng", | ||
"span.kind" : "test_module_end", | ||
"runtime.version" : ${content_meta_runtime_version}, | ||
"test.framework_version" : ${content_meta_test_framework_version}, | ||
"test.framework" : "testng" | ||
} | ||
} | ||
} ] |
1 change: 1 addition & 0 deletions
1
...ation/testng/testng-7/src/test/resources/test-parameterized-modifies-params/coverages.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ ] |
Oops, something went wrong.