ErrorUtil { public static String stackTraceString(Exception e) { StringWriter stackTrace = new StringWriter(); try (PrintWriter pw = new PrintWriter(stackTrace)) { e.printStackTrace(pw); return stackTrace.toString(); } }  static String fullExceptionDetails(Exception e); static String singleLineExceptionTrace(Exception e); static String stackTraceString(Exception e);  }
@Test public void testStackTraceString() { String res = ErrorUtil.stackTraceString(DUMMY_EXCEPTION); assertTrue(res.startsWith(firstTwoLinesStackTrace())); }