Example #1
0
  @Override
  public Object[] getInstances(boolean create) {
    Object[] result = {};

    if (m_xmlTest.isJUnit()) {
      if (create) {
        result =
            new Object[] {
              ClassHelper.createInstance(
                  m_class, m_classes, m_xmlTest, m_annotationFinder, m_objectFactory)
            };
      }
    } else {
      result = new Object[] {getDefaultInstance()};
    }
    if (m_instances.size() > 0) {
      result = m_instances.toArray(new Object[m_instances.size()]);
    }

    m_instanceCount = m_instances.size();
    m_instanceHashCodes = new long[m_instanceCount];
    for (int i = 0; i < m_instanceCount; i++) {
      m_instanceHashCodes[i] = m_instances.get(i).hashCode();
    }
    return result;
  }
Example #2
0
 /** Generate testng-failed.xml */
 private void createXmlTest(
     ITestContext context, List<ITestNGMethod> methods, XmlTest srcXmlTest) {
   XmlTest xmlTest = new XmlTest(m_xmlSuite);
   xmlTest.setName(context.getName() + "(failed)");
   xmlTest.setBeanShellExpression(srcXmlTest.getExpression());
   xmlTest.setIncludedGroups(srcXmlTest.getIncludedGroups());
   xmlTest.setExcludedGroups(srcXmlTest.getExcludedGroups());
   xmlTest.setParallel(srcXmlTest.getParallel());
   xmlTest.setParameters(srcXmlTest.getLocalParameters());
   xmlTest.setJUnit(srcXmlTest.isJUnit());
   List<XmlClass> xmlClasses = createXmlClasses(methods, srcXmlTest);
   xmlTest.setXmlClasses(xmlClasses);
 }
Example #3
0
  private static void toYaml(StringBuilder result, String sp, XmlTest t) {
    String sp2 = sp + "  ";
    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.getTestParameters());

    if (t.getIncludedGroups().size() > 0) {
      result
          .append(sp2)
          .append("includedGroups: [ ")
          .append(Utils.join(t.getIncludedGroups(), ","))
          .append(" ]\n");
    }

    if (t.getExcludedGroups().size() > 0) {
      result
          .append(sp2)
          .append("excludedGroups: [ ")
          .append(Utils.join(t.getExcludedGroups(), ","))
          .append(" ]\n");
    }

    Map<String, List<String>> mg = t.getMetaGroups();
    if (mg.size() > 0) {
      result.append(sp2).append("metaGroups: { ");
      boolean first = true;
      for (String group : mg.keySet()) {
        if (!first) result.append(", ");
        result.append(group).append(": [ ").append(Utils.join(mg.get(group), ",")).append(" ] ");
        first = false;
      }
      result.append(" }\n");
    }

    if (t.getXmlPackages().size() > 0) {
      result.append(sp2).append("xmlPackages:\n");
      for (XmlPackage xp : t.getXmlPackages()) {
        toYaml(result, sp2 + "  - ", xp);
      }
    }

    if (t.getXmlClasses().size() > 0) {
      result.append(sp2).append("classes:\n");
      for (XmlClass xc : t.getXmlClasses()) {
        toYaml(result, sp2 + "  ", xc);
      }
    }

    result.append("\n");
  }