org.testng.internal.Utils.shortStackTrace()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.testng.internal.Utils.shortStackTrace()方法的一些代码示例,展示了Utils.shortStackTrace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.shortStackTrace()方法的具体详情如下:
包路径:org.testng.internal.Utils
类名称:Utils
方法名:shortStackTrace

Utils.shortStackTrace介绍

[英]Helper that returns a long stack trace.
[中]返回长堆栈跟踪的助手。

代码示例

代码示例来源:origin: org.testng/testng

protected void generateExceptionReport(Throwable exception, ITestNGMethod method) {
 m_out.print("<div class=\"stacktrace\">");
 m_out.print(Utils.shortStackTrace(exception, true));
 m_out.println("</div>");
}

代码示例来源:origin: org.testng/testng

protected void writeStackTrace(Throwable throwable) {
  writer.print("<div class=\"stacktrace\">");
  writer.print(Utils.shortStackTrace(throwable, true));
  writer.print("</div>");
}

代码示例来源:origin: cbeust/testng

protected void writeStackTrace(Throwable throwable) {
 writer.print("<div class=\"stacktrace\">");
 writer.print(Utils.shortStackTrace(throwable, true));
 writer.print("</div>");
}

代码示例来源:origin: cbeust/testng

protected void generateExceptionReport(Throwable exception) {
 m_out.print("<div class=\"stacktrace\">");
 m_out.print(Utils.shortStackTrace(exception, true));
 m_out.println("</div>");
}

代码示例来源:origin: org.testng/testng

/**
 * @return an array of two strings: the short stack trace and the long stack trace.
 * @deprecated - Please consider using :
 * <ul>
 *     <li>{@link Utils#longStackTrace(Throwable, boolean)} - for getting full stack trace</li>
 *     <li>{@link Utils#shortStackTrace(Throwable, boolean)} - for getting short stack trace</li>
 * </ul>
 */
@Deprecated
public static String[] stackTrace(Throwable t, boolean toHtml) {
 return new String[] {
   shortStackTrace(t, toHtml), longStackTrace(t, toHtml)
 };
}

代码示例来源:origin: cbeust/testng

/**
 * @return an array of two strings: the short stack trace and the long stack trace.
 * @deprecated - Please consider using :
 *     <ul>
 *       <li>{@link Utils#longStackTrace(Throwable, boolean)} - for getting full stack trace
 *       <li>{@link Utils#shortStackTrace(Throwable, boolean)} - for getting short stack trace
 *     </ul>
 */
@Deprecated
public static String[] stackTrace(Throwable t, boolean toHtml) {
 return new String[] {shortStackTrace(t, toHtml), longStackTrace(t, toHtml)};
}

代码示例来源:origin: cbeust/testng

private void logExceptions(String status, List<ITestResult> results) {
 results.forEach(
   tr -> {
    Throwable throwable = tr.getThrowable();
    logResult(status, tr, throwable != null ? Utils.shortStackTrace(throwable, false) : null);
   });
}

代码示例来源:origin: org.testng/testng

private void createFailureElement(XMLStringBuffer doc, ITestResult tr) {
 Properties attrs= new Properties();
 Throwable t= tr.getThrowable();
 if(t != null) {
  attrs.setProperty(XMLConstants.ATTR_TYPE, t.getClass().getName());
  String message= t.getMessage();
  if((message != null) && (message.length() > 0)) {
   attrs.setProperty(XMLConstants.ATTR_MESSAGE, encodeAttr(message)); // ENCODE
  }
  doc.push(XMLConstants.FAILURE, attrs);
  doc.addCDATA(Utils.shortStackTrace(t, false));
  doc.pop();
 }
 else {
  doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR
 }
}

代码示例来源:origin: org.testng/testng

stackTrace = "<div><pre>" + Utils.shortStackTrace(tw, true)  + "</pre></div>";

代码示例来源:origin: cbeust/testng

private void createFailureElement(XMLStringBuffer doc, ITestResult tr) {
 Properties attrs = new Properties();
 Throwable t = tr.getThrowable();
 if (t != null) {
  attrs.setProperty(XMLConstants.ATTR_TYPE, t.getClass().getName());
  String message = t.getMessage();
  if ((message != null) && (message.length() > 0)) {
   attrs.setProperty(XMLConstants.ATTR_MESSAGE, encodeAttr(message)); // ENCODE
  }
  doc.push(XMLConstants.FAILURE, attrs);
  doc.addCDATA(Utils.shortStackTrace(t, false));
  doc.pop();
 } else {
  doc.addEmptyElement(XMLConstants.FAILURE); // THIS IS AN ERROR
 }
}

代码示例来源:origin: org.testng/testng

sb.append("SKIPPED");
  stackTrace = itr.getThrowable() != null
      ? Utils.shortStackTrace(itr.getThrowable(), false) : "";
  break;
case FAILURE:
  sb.append("FAILED");
  stackTrace = itr.getThrowable() != null
      ? Utils.shortStackTrace(itr.getThrowable(), false) : "";
  break;
case SUCCESS:

代码示例来源:origin: cbeust/testng

stackTrace = "<div><pre>" + Utils.shortStackTrace(tw, true) + "</pre></div>";

代码示例来源:origin: cbeust/testng

sb.append("SKIPPED");
 stackTrace =
   itr.getThrowable() != null ? Utils.shortStackTrace(itr.getThrowable(), false) : "";
 break;
case FAILURE:
 sb.append("FAILED");
 stackTrace =
   itr.getThrowable() != null ? Utils.shortStackTrace(itr.getThrowable(), false) : "";
 break;
case SUCCESS:

代码示例来源:origin: org.testng/testng

private void addTestResultException(XMLStringBuffer xmlBuffer, ITestResult testResult) {
 Throwable exception = testResult.getThrowable();
 if (exception != null) {
  Properties exceptionAttrs = new Properties();
  exceptionAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, exception.getClass().getName());
  xmlBuffer.push(XMLReporterConfig.TAG_EXCEPTION, exceptionAttrs);
  if (!Utils.isStringEmpty(exception.getMessage())) {
   xmlBuffer.push(XMLReporterConfig.TAG_MESSAGE);
   xmlBuffer.addCDATA(exception.getMessage());
   xmlBuffer.pop();
  }
  XMLReporterConfig.StackTraceLevels level = calculateStackTraceLevels(testResult);
  switch (level) {
   case SHORT:
    xmlBuffer.push(XMLReporterConfig.TAG_SHORT_STACKTRACE);
    xmlBuffer.addCDATA(Utils.shortStackTrace(exception, false));
    xmlBuffer.pop();
    break;
   case FULL:
    xmlBuffer.push(XMLReporterConfig.TAG_FULL_STACKTRACE);
    xmlBuffer.addCDATA(Utils.longStackTrace(exception, false));
    xmlBuffer.pop();
    break;
   default:
    //everything else is ignored for now.
  }
  xmlBuffer.pop();
 }
}

代码示例来源:origin: cbeust/testng

private static void generateReport(ITestResult result) {
  StringBuilder builder = new StringBuilder();
  String clsname = result.getTestClass().getRealClass().getName() + ".";
  String methodname = result.getMethod().getMethodName() + "()";
  builder.append(clsname).append(methodname);
  Object[] parameters = result.getParameters();
  if (parameters != null && parameters.length != 0) {
   builder.append("  Parameters:").append(Arrays.toString(parameters));
  }
  Throwable throwable = result.getThrowable();
  builder.append("\nException:\n");
  builder.append(Utils.shortStackTrace(throwable, false));
  builder.append("\n\n");
  System.err.println(builder.toString());
 }
}

代码示例来源:origin: org.testng/testng

String stackTrace = "";
if (ex != null && m_verbose >= 2) {
 stackTrace = Utils.shortStackTrace(ex, false);
String stackTrace= "";
if (ex != null && m_verbose >= 2) {
 stackTrace= Utils.shortStackTrace(ex, false);
logResult("SKIPPED", tr, throwable != null ? Utils.shortStackTrace(throwable, false) : null);

代码示例来源:origin: cbeust/testng

private void addTestResultException(XMLStringBuffer xmlBuffer, ITestResult testResult) {
 Throwable exception = testResult.getThrowable();
 if (exception != null) {
  Properties exceptionAttrs = new Properties();
  exceptionAttrs.setProperty(XMLReporterConfig.ATTR_CLASS, exception.getClass().getName());
  xmlBuffer.push(XMLReporterConfig.TAG_EXCEPTION, exceptionAttrs);
  if (!Utils.isStringEmpty(exception.getMessage())) {
   xmlBuffer.push(XMLReporterConfig.TAG_MESSAGE);
   xmlBuffer.addCDATA(exception.getMessage());
   xmlBuffer.pop();
  }
  XMLReporterConfig.StackTraceLevels level = calculateStackTraceLevels(testResult);
  switch (level) {
   case SHORT:
    xmlBuffer.push(XMLReporterConfig.TAG_SHORT_STACKTRACE);
    xmlBuffer.addCDATA(Utils.shortStackTrace(exception, false));
    xmlBuffer.pop();
    break;
   case FULL:
    xmlBuffer.push(XMLReporterConfig.TAG_FULL_STACKTRACE);
    xmlBuffer.addCDATA(Utils.longStackTrace(exception, false));
    xmlBuffer.pop();
    break;
   default:
    // everything else is ignored for now.
  }
  xmlBuffer.pop();
 }
}

代码示例来源:origin: org.testng/testng

stackTrace.append(Utils.shortStackTrace(tr.getThrowable(), true));
xsb.addOptional(D, stackTrace.toString() + "\n",
  C, "stack-trace");

代码示例来源:origin: cbeust/testng

String stackTrace = "";
if (ex != null && m_verbose >= 2) {
 stackTrace = Utils.shortStackTrace(ex, false);
String stackTrace = "";
if (ex != null && m_verbose >= 2) {
 stackTrace = Utils.shortStackTrace(ex, false);

代码示例来源:origin: cbeust/testng

stackTrace.append(Utils.shortStackTrace(tr.getThrowable(), true));
xsb.addOptional(D, stackTrace.toString() + "\n", C, "stack-trace");

相关文章