use of org.testng.xml.XmlSuite in project druid by druid-io.
the class TestNG method checkSuiteNamesInternal.
private void checkSuiteNamesInternal(List<XmlSuite> suites, Set<String> names) {
for (XmlSuite suite : suites) {
final String name = suite.getName();
if (names.contains(name)) {
throw new TestNGException("Two suites cannot have the same name: " + name);
}
names.add(name);
checkSuiteNamesInternal(suite.getChildSuites(), names);
}
}
use of org.testng.xml.XmlSuite in project druid by druid-io.
the class TestNG method checkTestNames.
/**
* Ensure that two XmlTest within the same XmlSuite don't have the same name
*/
private void checkTestNames(List<XmlSuite> suites) {
for (XmlSuite suite : suites) {
Set<String> testNames = Sets.newHashSet();
for (XmlTest test : suite.getTests()) {
if (testNames.contains(test.getName())) {
throw new TestNGException("Two tests in the same suite " + "cannot have the same name: " + test.getName());
} else {
testNames.add(test.getName());
}
}
checkTestNames(suite.getChildSuites());
}
}
use of org.testng.xml.XmlSuite in project intellij-community by JetBrains.
the class IDEARemoteTestNG method run.
public void run() {
try {
initializeSuitesAndJarFile();
List<XmlSuite> suites = Lists.newArrayList();
calculateAllSuites(m_suites, suites);
if (suites.size() > 0) {
for (XmlSuite suite : suites) {
final List<XmlTest> tests = suite.getTests();
for (XmlTest test : tests) {
try {
if (myParam != null) {
for (XmlClass aClass : test.getXmlClasses()) {
List<XmlInclude> includes = new ArrayList<XmlInclude>();
for (XmlInclude include : aClass.getIncludedMethods()) {
includes.add(new XmlInclude(include.getName(), Collections.singletonList(Integer.parseInt(myParam)), 0));
}
aClass.setIncludedMethods(includes);
}
}
} catch (NumberFormatException e) {
System.err.println("Invocation number: expected integer but found: " + myParam);
}
}
}
attachListeners(new IDEATestNGRemoteListener());
super.run();
System.exit(0);
} else {
System.out.println("##teamcity[enteredTheMatrix]");
System.err.println("Nothing found to run");
}
} catch (Throwable cause) {
cause.printStackTrace(System.err);
}
}
use of org.testng.xml.XmlSuite in project intellij-community by JetBrains.
the class IDEARemoteTestNG method calculateAllSuites.
private static void calculateAllSuites(List<XmlSuite> suites, List<XmlSuite> outSuites) {
for (XmlSuite s : suites) {
outSuites.add(s);
calculateAllSuites(s.getChildSuites(), outSuites);
}
}
use of org.testng.xml.XmlSuite in project intellij-community by JetBrains.
the class TestNGXmlSuiteHelper method writeSuite.
public static File writeSuite(Map<String, Map<String, List<String>>> map, Map<String, String> testParams, String name, String rootPath, Logger logger) {
File xmlFile;
final XmlSuite xmlSuite = new XmlSuite();
xmlSuite.setParameters(testParams);
XmlTest xmlTest = new XmlTest(xmlSuite);
xmlTest.setName(name);
List<XmlClass> xmlClasses = new ArrayList<XmlClass>();
int idx = 0;
for (String className : map.keySet()) {
final XmlClass xmlClass = new XmlClass(className, idx++, false);
final Map<String, List<String>> collection = map.get(className);
if (collection != null) {
final ArrayList<XmlInclude> includedMethods = new ArrayList<XmlInclude>();
int mIdx = 0;
for (String methodName : collection.keySet()) {
final List<Integer> includes = new ArrayList<Integer>();
for (String include : collection.get(methodName)) {
try {
includes.add(Integer.parseInt(include));
} catch (NumberFormatException e) {
logger.log(e);
}
}
includedMethods.add(new XmlInclude(methodName, includes, mIdx++));
}
xmlClass.setIncludedMethods(includedMethods);
}
xmlClasses.add(xmlClass);
}
xmlTest.setXmlClasses(xmlClasses);
xmlFile = new File(rootPath, "temp-testng-customsuite.xml");
final String toXml = xmlSuite.toXml();
writeToFile(logger, xmlFile, toXml);
return xmlFile;
}
Aggregations