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

x33g5p2x  于2022-02-05 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(232)

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

Yaml.toYaml介绍

[英]The main entry point to convert an XmlSuite into YAML. This method is allowed to be used by external tools (e.g. Eclipse).
[中]将XmlSuite转换为YAML的主要入口点。外部工具(例如Eclipse)可以使用这种方法。

代码示例

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

private static void toYaml(StringBuilder sb, List<XmlPackage> packages) {
 if (!packages.isEmpty()) {
  sb.append("packages:\n");
  for (XmlPackage p : packages) {
   toYaml(sb, "  ", p);
  }
 }
 for (XmlPackage p : packages) {
  toYaml(sb, "  ", p);
 }
}

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

private static void toYaml(StringBuilder sb, List<XmlPackage> packages) {
 if (!packages.isEmpty()) {
  sb.append("packages:\n");
  for (XmlPackage p : packages) {
   toYaml(sb, "  ", p);
  }
 }
 for (XmlPackage p : packages) {
  toYaml(sb, "  ", p);
 }
}

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

private static void toYaml(StringBuilder result, String sp2, XmlClass xc) {
 List<XmlInclude> im = xc.getIncludedMethods();
 List<String> em = xc.getExcludedMethods();
 String name = (im.isEmpty() && em.isEmpty()) ? "" : "name: ";
 result.append(sp2).append("- ").append(name).append(xc.getName()).append("\n");
 if (!im.isEmpty()) {
  result.append(sp2).append("  includedMethods:\n");
  for (XmlInclude xi : im) {
   toYaml(result, sp2 + "    ", xi);
  }
 }
 if (!em.isEmpty()) {
  result.append(sp2).append("  excludedMethods:\n");
  toYaml(result, sp2 + "    ", em);
 }
}

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

private static void toYaml(StringBuilder result, String sp, XmlInclude xi) {
 result.append(sp).append("- name: ").append(xi.getName()).append("\n");
 String sp2 = sp + "  ";
 toYaml(result, sp2, xi.getLocalParameters());
}

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

private static void toYaml(StringBuilder result, String sp2, XmlClass xc) {
 List<XmlInclude> im = xc.getIncludedMethods();
 List<String> em = xc.getExcludedMethods();
 String name = (im.isEmpty() && em.isEmpty()) ? "" : "name: ";
 result.append(sp2).append("- ").append(name).append(xc.getName()).append("\n");
 if (!im.isEmpty()) {
  result.append(sp2).append("  includedMethods:\n");
  for (XmlInclude xi : im) {
   toYaml(result, sp2 + "    ", xi);
  }
 }
 if (!em.isEmpty()) {
  result.append(sp2).append("  excludedMethods:\n");
  toYaml(result, sp2 + "    ", em);
 }
}

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

writeFile(newFile, Yaml.toYaml(suite).toString());

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

toYaml(result, "parameters", sp2, t.getLocalParameters());
 result.append(sp2).append("xmlPackages:\n");
 for (XmlPackage xp : t.getXmlPackages())  {
  toYaml(result, sp2 + "  - ", xp);
 result.append(sp2).append("classes:\n");
 for (XmlClass xc : t.getXmlClasses())  {
  toYaml(result, sp2 + "  ", xc);

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

writeFile(newFile, Yaml.toYaml(suite).toString());
} else if (file.endsWith(".yaml")) {
 File newFile = new File(m_outputDirectory, baseName + ".xml");

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

XmlSuite.DEFAULT_SKIP_FAILED_INVOCATION_COUNTS);
toYaml(result, "parameters", "", suite.getParameters());
toYaml(result, suite.getPackages());
 toYaml(result, "  ", suite.getListeners());
 toYaml(result, suite.getPackages());
  toYaml(result, "  ", t);
 toYaml(result, "  ", suite.getSuiteFiles());

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

toYaml(result, sp2, t.getLocalParameters());
 result.append(sp2).append("xmlPackages:\n");
 for (XmlPackage xp : t.getXmlPackages()) {
  toYaml(result, sp2 + "  - ", xp);
 result.append(sp2).append("classes:\n");
 for (XmlClass xc : t.getXmlClasses()) {
  toYaml(result, sp2 + "  ", xc);

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

@Test(description = "GITHUB-1787")
public void testParameterInclusion() throws IOException {
 SuiteXmlParser parser = new SuiteXmlParser();
 String file = "src/test/resources/yaml/1787.xml";
 XmlSuite xmlSuite = parser.parse(file, new FileInputStream(file), false);
 StringBuilder yaml = org.testng.internal.Yaml.toYaml(xmlSuite);
 Matcher m = Pattern.compile("parameters:").matcher(yaml.toString());
 int count = 0;
 while (m.find()) {
  count++;
 }
 assertThat(count).isEqualTo(5);
 File newSuite = File.createTempFile("suite", ".xml");
 newSuite.deleteOnExit();
 Files.writeFile(yaml.toString(), newSuite);
 assertThat(parser.parse(newSuite.getAbsolutePath(), new FileInputStream(file), false))
     .isEqualTo(xmlSuite);
}

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

XmlSuite.DEFAULT_SKIP_FAILED_INVOCATION_COUNTS);
toYaml(result, "", suite.getParameters());
toYaml(result, suite.getPackages());
 toYaml(result, "  ", suite.getListeners());
 toYaml(result, suite.getPackages());
  toYaml(result, t);
 toYaml(result, "  ", suite.getSuiteFiles());

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

StringBuilder yamlSb = Yaml.toYaml(suites.iterator().next());

相关文章