use of org.testng.xml.XmlInclude in project powermock by powermock.
the class SimpleBaseTest method addMethods.
protected void addMethods(XmlClass cls, String... methods) {
int index = 0;
for (String m : methods) {
XmlInclude include = new XmlInclude(m, index++);
cls.getIncludedMethods().add(include);
}
}
use of org.testng.xml.XmlInclude 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.XmlInclude 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;
}
use of org.testng.xml.XmlInclude in project intellij-community by JetBrains.
the class TestNGTreeHierarchyTest method testOneTestMethodWithMultipleInvocationCount.
@Test
public void testOneTestMethodWithMultipleInvocationCount() throws Exception {
final XmlSuite suite = new XmlSuite();
final XmlTest test = new XmlTest();
final XmlClass xmlClass = new XmlClass("a.ATest", false);
xmlClass.getIncludedMethods().add(new XmlInclude("test1", Arrays.asList(0, 1, 2), 0));
test.getClasses().add(xmlClass);
suite.getTests().add(test);
doTest(suite, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[0|]']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[1|] (1)' locationHint='java:test://a.ATest.test1|[1|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[1|] (1)']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[2|] (2)' locationHint='java:test://a.ATest.test1|[2|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[2|] (2)']\n");
}
use of org.testng.xml.XmlInclude in project intellij-community by JetBrains.
the class TestNGTreeHierarchyTest method testOneTestMethod.
@Test
public void testOneTestMethod() throws Exception {
final XmlSuite suite = new XmlSuite();
final XmlTest test = new XmlTest();
final XmlClass xmlClass = new XmlClass("a.ATest", false);
xmlClass.getIncludedMethods().add(new XmlInclude("test1"));
test.getClasses().add(xmlClass);
suite.getTests().add(test);
doTest(suite, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.test1|[0|]' locationHint='java:test://a.ATest.test1|[0|]']\n" + "\n" + "##teamcity[testFinished name='ATest.test1|[0|]']\n");
}
Aggregations