org.testng.internal.Yaml类的使用及代码示例

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

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

Yaml介绍

[英]YAML support for TestNG.
[中]YAML对TestNG的支持。

代码示例

代码示例来源: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: org.testng/testng

private static void toYaml(StringBuilder sb, String sp, XmlPackage p) {
 sb.append(sp).append("name: ").append(p.getName()).append("\n");
 generateIncludeExclude(sb, sp, "includes", p.getInclude());
 generateIncludeExclude(sb, sp, "excludes", p.getExclude());
}

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

private static void toYaml(StringBuilder sb, String key, String sp,
  Map<String, String> parameters) {
 if (!parameters.isEmpty()) {
  sb.append(sp).append(key).append(": ");
  mapToYaml(parameters, sb);
 }
}

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

StringBuilder result = new StringBuilder();
maybeAdd(result, "name", suite.getName(), null);
maybeAdd(result, "junit", suite.isJUnit(), XmlSuite.DEFAULT_JUNIT);
maybeAdd(result, "verbose", suite.getVerbose(), XmlSuite.DEFAULT_VERBOSE);
maybeAdd(result, "threadCount", suite.getThreadCount(), XmlSuite.DEFAULT_THREAD_COUNT);
maybeAdd(result, "dataProviderThreadCount", suite.getDataProviderThreadCount(),
  XmlSuite.DEFAULT_DATA_PROVIDER_THREAD_COUNT);
maybeAdd(result, "timeOut", suite.getTimeOut(), null);
maybeAdd(result, "parallel", suite.getParallel(), XmlSuite.DEFAULT_PARALLEL);
maybeAdd(result, "configFailurePolicy", suite.getConfigFailurePolicy().toString(), XmlSuite.DEFAULT_CONFIG_FAILURE_POLICY);
maybeAdd(result, "skipFailedInvocationCounts", suite.skipFailedInvocationCounts(),
  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: org.testng/testng

private static void maybeAdd(StringBuilder sb, String key, Object value, Object def) {
 maybeAdd(sb, "", key, value, def);
}

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

@Override
public XmlSuite parse(String filePath, InputStream is, boolean loadClasses)
  throws TestNGException {
 try {
  return Yaml.parse(filePath, is);
 } catch (FileNotFoundException e) {
  throw new TestNGException(e);
 }
}

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

result.append(sp).append("- name: ").append(t.getName()).append("\n");
maybeAdd(result, sp2, "junit", t.isJUnit(), XmlSuite.DEFAULT_JUNIT);
maybeAdd(result, sp2, "verbose", t.getVerbose(), XmlSuite.DEFAULT_VERBOSE);
maybeAdd(result, sp2, "timeOut", t.getTimeOut(), null);
maybeAdd(result, sp2, "parallel", t.getParallel(), XmlSuite.DEFAULT_PARALLEL);
maybeAdd(result, sp2, "skipFailedInvocationCounts", t.skipFailedInvocationCounts(),
  XmlSuite.DEFAULT_SKIP_FAILED_INVOCATION_COUNTS);
maybeAdd(result, "preserveOrder", sp2, t.getPreserveOrder(), XmlSuite.DEFAULT_PRESERVE_ORDER);
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

private static void maybeAdd(StringBuilder sb, String key, Object value, Object def) {
 maybeAdd(sb, "", key, value, def);
}

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

@Override
public XmlSuite parse(String filePath, InputStream is, boolean loadClasses)
  throws TestNGException {
 try {
  return Yaml.parse(filePath, is);
 } catch (FileNotFoundException e) {
  throw new TestNGException(e);
 }
}

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

maybeAdd(result, "name", suite.getName(), null);
maybeAdd(result, "junit", suite.isJUnit(), XmlSuite.DEFAULT_JUNIT);
maybeAdd(result, "verbose", suite.getVerbose(), XmlSuite.DEFAULT_VERBOSE);
maybeAdd(result, "threadCount", suite.getThreadCount(), XmlSuite.DEFAULT_THREAD_COUNT);
maybeAdd(
  result,
  "dataProviderThreadCount",
  suite.getDataProviderThreadCount(),
  XmlSuite.DEFAULT_DATA_PROVIDER_THREAD_COUNT);
maybeAdd(result, "timeOut", suite.getTimeOut(), null);
maybeAdd(result, "parallel", suite.getParallel(), XmlSuite.DEFAULT_PARALLEL);
maybeAdd(
  result,
  "configFailurePolicy",
  suite.getConfigFailurePolicy().toString(),
  XmlSuite.DEFAULT_CONFIG_FAILURE_POLICY);
maybeAdd(
  result,
  "skipFailedInvocationCounts",
toYaml(result, "", suite.getParameters());
toYaml(result, suite.getPackages());
 toYaml(result, "  ", suite.getListeners());
 toYaml(result, suite.getPackages());
  toYaml(result, t);

代码示例来源: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: cbeust/testng

private static void toYaml(StringBuilder sb, String sp, XmlPackage p) {
 sb.append(sp).append("name: ").append(p.getName()).append("\n");
 generateIncludeExclude(sb, sp, "includes", p.getInclude());
 generateIncludeExclude(sb, sp, "excludes", p.getExclude());
}

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

private static void toYaml(
  StringBuilder sb, String sp, Map<String, String> parameters) {
 if (!parameters.isEmpty()) {
  sb.append(sp).append("parameters").append(": ");
  mapToYaml(parameters, sb);
 }
}

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

result.append("  ").append("- name: ").append(t.getName()).append("\n");
maybeAdd(result, sp2, "junit", t.isJUnit(), XmlSuite.DEFAULT_JUNIT);
maybeAdd(result, sp2, "verbose", t.getVerbose(), XmlSuite.DEFAULT_VERBOSE);
maybeAdd(result, sp2, "timeOut", t.getTimeOut(), null);
maybeAdd(result, sp2, "parallel", t.getParallel(), XmlSuite.DEFAULT_PARALLEL);
maybeAdd(
  result,
  sp2,
  XmlSuite.DEFAULT_SKIP_FAILED_INVOCATION_COUNTS);
maybeAdd(result, "preserveOrder", sp2, t.getPreserveOrder(), XmlSuite.DEFAULT_PRESERVE_ORDER);
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: 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: cbeust/testng

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

代码示例来源: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);
}

相关文章