Add tests for Utils.getStackTraceAsString()
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Utils.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Utils.java
@@ -84,6 +84,9 @@ public class Utils {
return type.getDeclaredMethods().filter(named(methodName)).getOnly();
}
+ /**
+ * @return The current stack trace with multiple entries on new lines.
+ */
public static String getStackTraceAsString() {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
StringBuilder stringBuilder = new StringBuilder();

ADD
dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/UtilsTest.groovy
+package datadog.trace.agent.tooling
+
+import spock.lang.Specification
+
+
+class UtilsTest extends Specification {
+
+ def "getStackTraceAsString() returns the stack trace as a single new line separated string"() {
+ setup:
+ def stackTrace = Utils.stackTraceAsString
+
+ expect:
+ stackTrace.contains('datadog.trace.agent.tooling.Utils')
+ stackTrace.contains(System.getProperty("line.separator"))
+ }
+}

Add tests for Utils.getStackTraceAsString()