gpt4 book ai didi

org.testng.reporters.XMLStringBuffer.addOptional()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 20:54:40 25 4
gpt4 key购买 nike

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

XMLStringBuffer.addOptional介绍

[英]Add an optional Boolean element to the current tag. If value is null, nothing is added.
[中]向当前标记添加可选的布尔元素。如果值为null,则不添加任何内容。

代码示例

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

/**
 * Add an optional String element to the current tag.  If value is null, nothing is
 * added.
 * @param tagName The name of the tag
 * @param value The value for this tag
 */
public void addOptional(String tagName, @Nullable String value) {
 addOptional(tagName, value, (Properties) null);
}

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

/**
 * Add an optional Boolean element to the current tag.  If value is null, nothing is
 * added.
 * @param tagName The name of the tag
 * @param value The value for this tag
 */
public void addOptional(String tagName, @Nullable Boolean value) {
 addOptional(tagName, value, null);
}

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

/**
 * Add an optional Boolean element to the current tag. If value is null, nothing is added.
 *
 * @param tagName The name of the tag
 * @param value The value for this tag
 */
public void addOptional(String tagName, @Nullable Boolean value) {
 addOptional(tagName, value, null);
}

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

/**
 * Add an optional String element to the current tag. If value is null, nothing is added.
 *
 * @param tagName The name of the tag
 * @param value The value for this tag
 */
public void addOptional(String tagName, @Nullable String value) {
 addOptional(tagName, value, (Properties) null);
}

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

private void generateMethod(String tagClass, ITestResult tr,
  ITestContext context, XMLStringBuffer xsb) {
 long time = tr.getEndMillis() - tr.getStartMillis();
 xsb.push(D, C, "method");
 xsb.push(D, C, "method-content");
 xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name");
 // Parameters?
 if (tr.getParameters().length > 0) {
  StringBuilder sb = new StringBuilder();
  boolean first = true;
  for (Object p : tr.getParameters()) {
   if (!first) sb.append(", ");
   first = false;
   sb.append(Utils.toString(p));
  }
  xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters");
 }
 // Exception?
 if (tr.getThrowable() != null) {
  StringBuilder stackTrace = new StringBuilder();
  for (StackTraceElement str : tr.getThrowable().getStackTrace()) {
   stackTrace.append(str.toString()).append("<br>");
  }
  xsb.addOptional(D, stackTrace.toString() + "\n",
    C, "stack-trace");
 }
 xsb.addOptional(S, " " + Long.toString(time) + " ms", C, "method-time");
 xsb.pop(D);
 xsb.pop(D);
}

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

private void addLinkTo(XMLStringBuffer header, INavigatorPanel panel, ISuite suite) {
 String text = panel.getNavigatorLink(suite);
 header.push("li");
 header.push("a", "href", "#",
   "panel-name", panel.getPanelName(suite),
   C, "navigator-link ");
 String className = panel.getClassName();
 if (className != null) {
  header.addOptional(S, text, C, className);
 } else {
  header.addOptional(S, text);
 }
 header.pop("a");
 header.pop("li");
}

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

private void addLinkTo(XMLStringBuffer header, INavigatorPanel panel, ISuite suite) {
 String text = panel.getNavigatorLink(suite);
 header.push("li");
 header.push("a", "href", "#", "panel-name", panel.getPanelName(suite), C, "navigator-link ");
 String className = panel.getClassName();
 if (className != null) {
  header.addOptional(S, text, C, className);
 } else {
  header.addOptional(S, text);
 }
 header.pop("a");
 header.pop("li");
}

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

xsb.push("a", "name", Model.getTestResultName(tr));
xsb.pop("a");
xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name");
  sb.append(Utils.toString(p));
 xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters");
 StringBuilder stackTrace = new StringBuilder();
 stackTrace.append(Utils.shortStackTrace(tr.getThrowable(), true));
 xsb.addOptional(D, stackTrace.toString() + "\n",
   C, "stack-trace");

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

@Test
public void testMethod() {
  IBuffer result = Buffer.create();
  XMLStringBuffer sb = new XMLStringBuffer(result, "");
  sb.push("family");
  Properties p = new Properties();
  p.setProperty("prop1", "value1");
  p.setProperty("prop2", "value2");
  sb.addRequired("cedric", "true", p);
  sb.addRequired("alois", "true");
  sb.addOptional("anne-marie", (String) null);
  sb.pop();
  String expected = "<family>" + EOL +
      "  <cedric prop2=\"value2\" prop1=\"value1\">true</cedric>" + EOL +
      "  <alois>true</alois>" + EOL +
      "</family>";
  assertThat(result.toString().trim()).isEqualTo(expected);
}

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

xsb.push("a", "name", Model.getTestResultName(tr));
xsb.pop("a");
xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name");
  sb.append(Utils.toString(p));
 xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters");
 StringBuilder stackTrace = new StringBuilder();
 stackTrace.append(Utils.shortStackTrace(tr.getThrowable(), true));
 xsb.addOptional(D, stackTrace.toString() + "\n", C, "stack-trace");

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

private void generateClassPanel(Class c, List<ITestResult> results, XMLStringBuffer xsb,
  String status, ISuite suite) {
 xsb.push(D, C, "suite-" + suiteToTag(suite) + "-class-" + status);
 xsb.push(D, C, "main-panel-header rounded-window-top");
 // Passed/failed icon
 xsb.addEmptyElement("img", "src", Model.getImage(status));
 xsb.addOptional(S, c.getName(), C, "class-name");
 xsb.pop(D);
 xsb.push(D, C, "main-panel-content rounded-window-bottom");
 for (ITestResult tr : results) {
  generateMethod(tr, xsb);
 }
 xsb.pop(D);
 xsb.pop(D);
}

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

private void generateClassPanel(
  Class c, List<ITestResult> results, XMLStringBuffer xsb, String status, ISuite suite) {
 xsb.push(D, C, "suite-" + suiteToTag(suite) + "-class-" + status);
 xsb.push(D, C, "main-panel-header rounded-window-top");
 // Passed/failed icon
 xsb.addEmptyElement("img", "src", Model.getImage(status));
 xsb.addOptional(S, c.getName(), C, "class-name");
 xsb.pop(D);
 xsb.push(D, C, "main-panel-content rounded-window-bottom");
 for (ITestResult tr : results) {
  generateMethod(tr, xsb);
 }
 xsb.pop(D);
 xsb.pop(D);
}

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

generateTests("passed", context.getPassedTests(), context, xs3);
xsb.addOptional(D, "Failed" + " tests", C, "result-banner " + "failed");
xsb.addString(xs1.toXML());
xsb.addOptional(D, "Skipped" + " tests", C, "result-banner " + "skipped");
xsb.addString(xs2.toXML());
xsb.addOptional(D, "Passed" + " tests", C, "result-banner " + "passed");
xsb.addString(xs3.toXML());
header.addOptional(S, suite.getName(), C, "suite-name");
header.push(D, C, "stats");
int total = failed + skipped + passed;
header.addOptional(S, stats, C, "method-stats");
header.pop("li");
header.addOptional(S, String.format("%s ", pluralize(results.values().size(), "test"),
  C, "test-stats"));
header.pop("li");
 String testName = tr.getTestContext().getName();
 header.push("li");
 header.addOptional("a", testName, "href", "#" + m_testMap.get(testName));
 header.pop("li");

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

@Override
public void generate(XMLStringBuffer xsb) {
 for (ISuite s : getSuites()) {
  xsb.push(D, C, "panel", "panel-name", getPanelName(s));
  xsb.push(D, C, "main-panel-header rounded-window-top");
  xsb.addOptional(S, getHeader(s), C, "header-content");
  xsb.pop(D);
  xsb.push(D, C, "main-panel-content rounded-window-bottom");
  xsb.addString(getContent(s, xsb));
  xsb.pop(D);
  xsb.pop(D);
 }
}

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

@Override
public void generate(XMLStringBuffer xsb) {
 for (ISuite s : getSuites()) {
  xsb.push(D, C, "panel", "panel-name", getPanelName(s));
  xsb.push(D, C, "main-panel-header rounded-window-top");
  xsb.addOptional(S, getHeader(s), C, "header-content");
  xsb.pop(D);
  xsb.push(D, C, "main-panel-content rounded-window-bottom");
  xsb.addString(getContent(s, xsb));
  xsb.pop(D);
  xsb.pop(D);
 }
}

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

private void generateResult(XMLStringBuffer header, int failed, int skipped, int passed,
  ISuite suite, String suiteName) {
 //
 // Results
 //
 header.push(D, C, "result-section");
 header.push(D, C, "suite-section-title");
 header.addRequired(S, "Results");
 header.pop(D);
 // Method stats
 int total = failed + skipped + passed;
 String stats = String.format("%s, %s %s %s",
   pluralize(total, "method"),
   maybe(failed, "failed", ", "),
   maybe(skipped, "skipped", ", "),
   maybe(passed, "passed", ""));
 header.push(D, C, "suite-section-content");
 header.push("ul");
 header.push("li");
 header.addOptional(S, stats, C, "method-stats");
 header.pop("li");
 generateMethodList("Failed methods", new ResultsByStatus(suite, "failed", ITestResult.FAILURE),
   suiteName, header);
 generateMethodList("Skipped methods", new ResultsByStatus(suite, "skipped", ITestResult.SKIP),
   suiteName, header);
 generateMethodList("Passed methods", new ResultsByStatus(suite, "passed", ITestResult.SUCCESS),
   suiteName, header);
 }

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

xsb.addOptional(S, c.getName(), C, "class-name");

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

header.push("ul");
header.push("li");
header.addOptional(S, stats, C, "method-stats");
header.pop("li");

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

"panel-name", suiteName,
  C, "navigator-link");
header.addOptional(S, suite.getName(),
  C, "suite-name border-" + getModel().getStatusForSuite(suite.getName()));
header.pop("a");

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

header.addOptional(
  S,
  suite.getName(),

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com