Skip to content

Commit 0fb58fb

Browse files
committed
feat(junit-4.10): Migrate to JSON component
1 parent 3a659c5 commit 0fb58fb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

dd-java-agent/instrumentation/junit-4.10/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ tasks.named("compileLatestDepTestGroovy").configure {
1717
}
1818

1919
dependencies {
20+
implementation project(':components:json:json-io')
21+
2022
compileOnly group: 'junit', name: 'junit', version: '4.10'
2123

2224
testImplementation testFixtures(project(':dd-java-agent:agent-ci-visibility'))

dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4Utils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package datadog.trace.instrumentation.junit4;
22

3+
import static datadog.json.io.JsonMapper.toJson;
4+
35
import datadog.trace.api.civisibility.config.TestIdentifier;
46
import datadog.trace.api.civisibility.events.TestDescriptor;
57
import datadog.trace.api.civisibility.events.TestSuiteDescriptor;
@@ -201,7 +203,7 @@ public static String getParameters(final Description description) {
201203

202204
// No public access to the test parameters map in JUnit4.
203205
// In this case, we store the fullTestName in the "metadata.test_name" object.
204-
return "{\"metadata\":{\"test_name\":\"" + Strings.escapeToJson(methodName) + "\"}}";
206+
return "{\"metadata\":{\"test_name\":\"" + toJson(methodName) + "\"}}";
205207
}
206208

207209
public static List<String> getCategories(Class<?> testClass, @Nullable Method testMethod) {

0 commit comments

Comments
 (0)