@Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test1(LinkedHashMap<String, String> data) {
}
@Test(priority = 2, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test2(LinkedHashMap<String, String> data) {}@Test(priority =3, dataProvider = "getData", dataProviderClass = DataUtil.class)
public void Test3(LinkedHashMap<String, String> data) {}
Why not set them via a listener implementation of org.testng.IAnnotationTransformer2 and then plug in this listener using <listeners> tag or an SPI (Service Loader implementation)
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
public static class DataProviderAdder implements IAnnotationTransformer {
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
if (annotation != null) {
annotation.setDataProvider("someDataProvider");
annotation.setDataProviderClass(SampleClass.class);
}
}
}
This should get you started.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
static List<Class> listenerClasses = new ArrayList<Class>();
public static List<XmlSuite> genarateXmlFile() {
XmlSuite suite = new XmlSuite();
suite.setName(Constant.BaseTestHelperConstant.SUITENAME);
XmlTest test = new XmlTest(suite);
test.setName(Constant.BaseTestHelperConstant.TESTCASENAME);
test.setGroupByInstances(true);
List<XmlClass> classes = new ArrayList<XmlClass>();
for (int i = 0; i < Common.BaseTestHelperClass.sheetsName.size(); i++)
classes.add(new XmlClass(Constant.BaseTestHelperConstant.TESTSUITEPATH + Common.BaseTestHelperClass.sheetsName.get(i)));
listenerClasses.add(main.java.com.agrostar.utility.DataProviderAdder.class);
test.setXmlClasses(classes);
List<XmlSuite> suites = new ArrayList<XmlSuite>();
suites.add(suite);
System.out.println("Printing TestNG Suite Xml");
System.out.println(suite.toXml());
return suites;
}
public static void runXmlSuite(List<XmlSuite> suites) {
TestNG tng = new TestNG();
tng.setXmlSuites(suites);
tng.setListenerClasses(listenerClasses);
tng.run();
}
Either use tng.addListener() or
Change listenerClasses definition to :
List<Class<? extends ITestNGListener>> = new Array list<>()
package main.java.com.agrostar.utility;
import org.testng.IAnnotationTransformer;
import org.testng.annotations.ITestAnnotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class DataProviderAdder implements IAnnotationTransformer {
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
if (annotation != null) {
annotation.setDataProvider("getData");
annotation.setDataProviderClass(DataUtil.class);
}
}
}
public static List<XmlSuite> genarateXmlFile() {
List<XmlTest> tests = new ArrayList<XmlTest>();
List<XmlSuite> suites = new ArrayList<XmlSuite>();
XmlSuite suite = new XmlSuite();
suite.setName(Constant.BaseTestHelperConstant.SUITENAME);
suite.setPreserveOrder(true);
for (int i = 0; i < Common.BaseTestHelperClass.sheetsName.size(); i++) {
XmlTest test = new XmlTest(suite);
List<XmlClass> classes = new ArrayList<XmlClass>();
test.setName(Common.BaseTestHelperClass.sheetsName.get(i));
classes.add(new XmlClass(Constant.BaseTestHelperConstant.TESTSUITEPATH + Common.BaseTestHelperClass.sheetsName.get(i)));
test.setXmlClasses(classes);
tests.add(test);
}
listenerClasses.add(main.java.com.agrostar.utility.DataProviderAdder.class);
suites.add(suite);
System.out.println("Printing TestNG Suite Xml");
System.out.println(suite.toXml());
System.out.println("suites---------" + suites);
return suites;
}