code: public static String getTrimmedStackTrace(Throwable exception) {
          List<String> trimmedStackTraceLines = getTrimmedStackTraceLines(exception);
          if (trimmedStackTraceLines.isEmpty()) {
              return getFullStackTrace(exception);
          }
  
          StringBuilder result = new StringBuilder(exception.toString());
          appendStackTraceLines(trimmedStackTraceLines, result);
          appendStackTraceLines(getCauseStackTraceLines(exception), result);
          return result.toString();
      }
docs: Gets a trimmed version of the stack trace of the given exception. Stack trace
  elements that are below the test method are filtered out.
  
  @return a trimmed stack trace, or the original trace if trimming wasn't possible