Package org.testng.reporters

Examples of org.testng.reporters.XMLStringBuffer


    return pluralize(suite.getExcludedMethods().size(), "ignored method");
  }

  @Override
  public String getContent(ISuite suite, XMLStringBuffer main) {
    XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent());
    SetMultiMap<Class<?>, ITestNGMethod> map = Maps.newSetMultiMap();

    for (ITestNGMethod method : suite.getExcludedMethods()) {
      map.put(method.getTestClass().getRealClass(), method);
    }

    for (Class<?> c : map.getKeys()) {
      xsb.push(D, C, "ignored-class-div");
      xsb.addRequired(S, c.getName(), C, "ignored-class-name");
      xsb.push(D, C, "ignored-methods-div");
      for (ITestNGMethod m : map.get(c)) {
        xsb.addRequired(S, m.getMethodName(), C, "ignored-method-name");
        xsb.addEmptyElement("br");
      }
      xsb.pop(D);
      xsb.pop(D);
    }
    return xsb.toXML();
  }
View Full Code Here


        continue;
      }

      String suiteName = "suite-" + suiteToTag(suite);

      XMLStringBuffer header = new XMLStringBuffer(main.getCurrentIndent());

      Map<String, ISuiteResult> results = suite.getResults();
      int failed = 0;
      int skipped = 0;
      int passed = 0;
      for (ISuiteResult result : results.values()) {
        ITestContext context = result.getTestContext();
        failed += context.getFailedTests().size();
        skipped += context.getSkippedTests().size();
        passed += context.getPassedTests().size();
      }

      // Suite name in big font
      header.push(D, C, "suite");
      header.push(D, C, "rounded-window");
      // Extra div so the highlighting logic will only highlight this line and not
      // the entire container
      header.push(D, C, "suite-header light-rounded-window-top");
      header.push("a", "href", "#",
          "panel-name", suiteName,
          C, "navigator-link");
      header.addOptional(S, suite.getName(),
          C, "suite-name border-" + getModel().getStatusForSuite(suite.getName()));
      header.pop("a");
      header.pop(D);

      header.push(D, C, "navigator-suite-content");

      generateInfo(header, suite);
      generateResult(header, failed, skipped, passed, suite, suiteName);

      header.pop("ul");

      header.pop(D); // suite-section-content
      header.pop(D); // suite-header
      header.pop(D); // suite

      header.pop(D); // result-section

      header.pop(D); // navigator-suite-content

      main.addString(header.toXML());
    }
    main.pop(D);
  }
View Full Code Here

  private void ppp(String s) {
    System.out.println("[XmlMethodSelector] " + s);
  }
 
  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);

    xsb.push("method-selector");
   
    if (null != m_className) {
      Properties clsProp = new Properties();
      clsProp.setProperty("name", getClassName());
      if(getPriority() != -1) {
        clsProp.setProperty("priority", String.valueOf(getPriority()));
      }
      xsb.addEmptyElement("selector-class", clsProp);
    }
    else if (getLanguage() != null) {
      Properties scriptProp = new Properties();
      scriptProp.setProperty("language", getLanguage());
      xsb.push("script", scriptProp);
      xsb.addCDATA(getExpression());
      xsb.pop("script");
    }
    else {
      throw new TestNGException("Invalid Method Selector:  found neither class name nor language");
    }
   
    xsb.pop("method-selector");

    return xsb.toXML();
  }
View Full Code Here

    }
  }

  private void generateMethodList(String name, IResultProvider provider,
      String suiteName, XMLStringBuffer main) {
    XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent());
    String type = provider.getType();
    String image = Model.getImage(type);

    xsb.push("li");

    // The methods themselves
    xsb.addRequired(S, name, C, "method-list-title " + type);

    // The mark up to show the (hide)/(show) links
    xsb.push(S, C, "show-or-hide-methods " + type);
    xsb.addRequired("a", " (hide)", "href", "#", C, "hide-methods " + type + " " + suiteName,
        "panel-name", suiteName);
    xsb.addRequired("a", " (show)", "href", "#",C, "show-methods " + type + " " + suiteName,
        "panel-name", suiteName);
    xsb.pop(S);

    // List of methods
    xsb.push(D, C, "method-list-content " + type + " " + suiteName);
    int count = 0;
    List<ITestResult> testResults = provider.getResults();
    if (testResults != null) {
      Collections.sort(testResults, ResultsByClass.METHOD_NAME_COMPARATOR);
      for (ITestResult tr : testResults) {
        String testName = Model.getTestResultName(tr);
        xsb.push(S);
        xsb.addEmptyElement("img", "src", image, "width", "3%");
        xsb.addRequired("a", testName, "href", "#",
            "hash-for-method", getModel().getTag(tr),
            "panel-name", suiteName,
            "title", tr.getTestClass().getName(),
            C, "method navigator-link");
        xsb.pop(S);
        xsb.addEmptyElement("br");
        count++;
      }
    }
    xsb.pop(D);
    xsb.pop("li");

    if (count > 0) {
      main.addString(xsb.toXML());
    }
  }
View Full Code Here

    return "Tests for " + suite.getName();
  }

  @Override
  public String getContent(ISuite suite, XMLStringBuffer main) {
    XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent());

    xsb.push("ul");
    for (XmlTest test : suite.getXmlSuite().getTests()) {
      xsb.push("li");
      int count = test.getXmlClasses().size();
      String name = test.getName() + " (" + pluralize(count, "class") + ")";
      xsb.addRequired(S, name, C, "test-name");
      xsb.pop("li");
    }
    xsb.pop("ul");

    return xsb.toXML();
  }
View Full Code Here

    return "Groups for " + suite.getName();
  }

  @Override
  public String getContent(ISuite suite, XMLStringBuffer main) {
    XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent());
    List<String> sortedGroups = getModel().getGroups(suite.getName());
    Collections.sort(sortedGroups);
    for (String group : sortedGroups) {
      xsb.push(D, C, "test-group");
      xsb.addRequired(S, group, C, "test-group-name");
      xsb.addEmptyElement("br");
      List<String> sortedMethods = getModel().getMethodsInGroup(group);
      for (String method : sortedMethods) {
        xsb.push(D, C, "method-in-group");
        xsb.addRequired(S, method, C, "method-in-group-name");
        xsb.addEmptyElement("br");
        xsb.pop(D);
      }
      xsb.pop(D);
    }
    return xsb.toXML();
  }
View Full Code Here

  public String getExpression() {
    return m_expression;
  }

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    Properties p = new Properties();
    p.setProperty("name", getName());
    p.setProperty("junit", m_isJUnit != null ? m_isJUnit.toString() : "false");
    if (null != m_parallel && !"".equals(m_parallel)) {
      p.setProperty("parallel", m_parallel);
    }
    if (null != m_verbose) {
      p.setProperty("verbose", m_verbose.toString());
    }
    if (null != m_annotations) {
      p.setProperty("annotations", m_annotations.toString());
    }
    if (null != m_timeOut) {
      p.setProperty("time-out", m_timeOut.toString());
    }
    if (m_preserveOrder != null) {
      p.setProperty("preserve-order", m_preserveOrder.toString());
    }
   
    xsb.push("test", p);
   
   
    if (null != getMethodSelectors() && !getMethodSelectors().isEmpty()) {
      xsb.push("method-selectors");
      for (XmlMethodSelector selector: getMethodSelectors()) {
        xsb.getStringBuffer().append(selector.toXml(indent + "    "));
      }
     
      xsb.pop("method-selectors");
    }
   
    // parameters
    if (!m_parameters.isEmpty()) {
      for(Map.Entry<String, String> para: m_parameters.entrySet()) {
        Properties paramProps= new Properties();
        paramProps.setProperty("name", para.getKey());
        paramProps.setProperty("value", para.getValue());
        xsb.addEmptyElement("parameter", paramProps); // BUGFIX: TESTNG-27
      }
    }
   
    // groups
    if (!m_metaGroups.isEmpty() || !m_includedGroups.isEmpty() || !m_excludedGroups.isEmpty()) {
      xsb.push("groups");
     
      // define
      for (String metaGroupName: m_metaGroups.keySet()) {
        Properties metaGroupProp= new Properties();
        metaGroupProp.setProperty("name",  metaGroupName);
       
        xsb.push("define", metaGroupProp);
       
        for (String groupName: m_metaGroups.get(metaGroupName)) {
          Properties includeProps = new Properties();
          includeProps.setProperty("name", groupName);
         
          xsb.addEmptyElement("include", includeProps);
        }
       
        xsb.pop("define");
      }
     
      if (!m_includedGroups.isEmpty() || !m_excludedGroups.isEmpty()) {
        xsb.push("run");
       
        for (String includeGroupName: m_includedGroups) {
          Properties includeProps = new Properties();
          includeProps.setProperty("name", includeGroupName);
         
          xsb.addEmptyElement("include", includeProps);
        }
       
        for (String excludeGroupName: m_excludedGroups) {
          Properties excludeProps = new Properties();
          excludeProps.setProperty("name", excludeGroupName);
         
          xsb.addEmptyElement("exclude", excludeProps);
        }
       
        xsb.pop("run");
      }
     
      xsb.pop("groups");
    }
   
   
    // HINT: don't call getXmlPackages() cause you will retrieve the suite packages too
    if (null != m_xmlPackages && !m_xmlPackages.isEmpty()) {
      xsb.push("packages");
     
      for (XmlPackage pack: m_xmlPackages) {
        xsb.getStringBuffer().append(pack.toXml("  "));
      }
     
      xsb.pop("packages");
    }
   
    // classes
    if (null != getXmlClasses() && !getXmlClasses().isEmpty()) {
      xsb.push("classes");
      for (XmlClass cls : getXmlClasses()) {
        xsb.getStringBuffer().append(cls.toXml(indent + "    "));
      }
      xsb.pop("classes");
    }
   
    xsb.pop("test");
   
    return xsb.toXML();
  }
View Full Code Here

    return "Reporter output for " + suite.getName();
  }

  @Override
  public String getContent(ISuite suite, XMLStringBuffer main) {
    XMLStringBuffer xsb = new XMLStringBuffer(main.getCurrentIndent());
    for (ITestResult tr : getModel().getAllTestResults(suite)) {
      List<String> lines = Reporter.getOutput(tr);
      if (! lines.isEmpty()) {
        xsb.push(D, C, "reporter-method-div");
        xsb.addRequired(S, Model.getTestResultName(tr), C, "reporter-method-name");
        xsb.push(D, C, "reporter-method-output-div");
        for (String output : lines) {
          xsb.addRequired(S, output, C, "reporter-method-output");
        }
        xsb.pop(D);
        xsb.pop(D);
      }
    }
    return xsb.toXML();
  }
View Full Code Here

  public int getIndex() {
    return m_index;
  }

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    Properties p = new Properties();
    p.setProperty("name", getName());
    List<Integer> invocationNumbers = getInvocationNumbers();
    if (invocationNumbers != null && invocationNumbers.size() > 0) {
      p.setProperty("invocation-numbers", XmlClass.listToString(invocationNumbers).toString());
    }
    xsb.addEmptyElement("include", p);

    return xsb.toXML();
  }
View Full Code Here

   private void generateConfiguration(String[] classNames) {
      //
      // Create testng.xml
      //
      XMLStringBuffer xsb = new XMLStringBuffer("");
      xsb.setDocType("suite SYSTEM \"" + Parser.TESTNG_DTD_URL + "\"");
      Properties props = new Properties();
      props.setProperty("name", "Generated Suite");
      xsb.push("suite", props);
      props.setProperty("name", "Generated Test");
      xsb.push("test", props);
      xsb.push("classes");

      for(String className : classNames) {
         Properties p = new Properties();
         p.setProperty("name", className);
         xsb.addEmptyElement("class", p);
      }

      xsb.pop("classes");
      xsb.pop("test");
      xsb.pop("suite");

      Utils.writeFile(m_outDir.getAbsolutePath(), "testng.xml", xsb.toXML());
   }
View Full Code Here

TOP

Related Classes of org.testng.reporters.XMLStringBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.