diff --git a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4Utils.java b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4Utils.java index 23dec8dba88..445068b2f0d 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4Utils.java +++ b/dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4Utils.java @@ -293,6 +293,9 @@ public static boolean isTestSuiteDescription(final Description description) { public static boolean isSuiteContainingChildren(final Description description) { Class testClass = description.getTestClass(); + if (testClass == null) { + return false; + } for (Method method : testClass.getMethods()) { if (method.getAnnotation(Test.class) != null) { return true; diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy index 951987863c9..4ce257ef018 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy @@ -456,8 +456,8 @@ class JUnit4Test extends CiVisibilityTest { }) where: - testTags_0 = [(Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[0]"}}'] - testTags_1 = [(Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[1]"}}'] + testTags_0 = [(Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[str1]"}}'] + testTags_1 = [(Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[\\"str2\\"]"}}'] } def "test ITR skipping"() { @@ -529,11 +529,11 @@ class JUnit4Test extends CiVisibilityTest { where: testTags_0 = [ - (Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[0]"}}', + (Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[str1]"}}', (Tags.TEST_SKIP_REASON): "Skipped by Datadog Intelligent Test Runner", (Tags.TEST_SKIPPED_BY_ITR): true ] - testTags_1 = [(Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[1]"}}'] + testTags_1 = [(Tags.TEST_PARAMETERS): '{"metadata":{"test_name":"parameterized_test_succeed[\\"str2\\"]"}}'] } def "test ITR unskippable"() { diff --git a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestParameterized.java b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestParameterized.java index 8548bed51b7..4ddfbab870e 100644 --- a/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestParameterized.java +++ b/dd-java-agent/instrumentation/junit-4.10/src/test/java/org/example/TestParameterized.java @@ -11,7 +11,7 @@ @RunWith(Parameterized.class) public class TestParameterized { - @Parameterized.Parameters + @Parameterized.Parameters(name = "{1}") public static Collection data() { return Arrays.asList( new Object[][] {{new ParamObject(), "str1", 0}, {new ParamObject(), "\"str2\"", 1}});