All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testng.xml.XmlRun Maven / Gradle / Ivy

There is a newer version: 7.10.1
Show newest version
package org.testng.xml;

import static org.testng.collections.CollectionUtils.hasElements;

import org.testng.collections.Lists;
import org.testng.reporters.XMLStringBuffer;
import org.testng.xml.dom.OnElement;

import java.util.List;

public class XmlRun {

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    boolean hasElements = hasElements(m_excludes) || hasElements(m_includes);
    if (hasElements) {
      xsb.push("run");
    }
    for (String s : m_includes) {
      xsb.addEmptyElement("include", "name", s);
    }
    for (String s : m_excludes) {
      xsb.addEmptyElement("exclude", "name", s);
    }
    if (hasElements) {
      xsb.pop("run");
    }

    return xsb.toXML();
  }

  private List m_excludes = Lists.newArrayList();

  public List getExcludes() {
    return m_excludes;
  }

  @OnElement(tag = "exclude", attributes = "name")
  public void onExclude(String name) {
    m_excludes.add(name);
  }

  private List m_includes = Lists.newArrayList();

  public List getIncludes() {
    return m_includes;
  }

  @OnElement(tag = "include", attributes = "name")
  public void onInclude(String name) {
    m_includes.add(name);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy