org.testng.xml.XmlRun Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testng Show documentation
Show all versions of testng Show documentation
Testing framework for Java
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);
}
}