public class DemoClass {
public static void main(String[] args) {
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[] { MyTestClass.class });
testNG.setVerbose(3);
testNG.run();
}
public static class MyTestClass implements ITest{
private String name;
@Factory(dataProvider = "dp")
public MyTestClass(String name) {
this.name = name;
}
@DataProvider(name = "dp")
public static Object[][] generateObjects() {
return new Object[][] { { "Cedric" }, { "Beust" } };
}
@Test
public void testMethod() {
Assert.assertNotNull(this.name);
}
@Override
public String getTestName() {
return name;
}
}
}
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
public class MyTestNGClass {
public static void main(String[] args) {
TestNG testng = new TestNG();
XmlTest xmlTest = new XmlTest();
xmlTest.setName("Sample Test");
xmlTest.addParameter("myParameterString", "KungFu Panda");
xmlTest.setClasses(Arrays.asList(new XmlClass(LocalTestClass.class)));
XmlSuite xmlSuite = new XmlSuite();
xmlSuite.setName("Sample Suite");
xmlTest.setSuite(xmlSuite);
xmlSuite.setTests(Arrays.asList(xmlTest));
testng.setXmlSuites(Arrays.asList(xmlSuite));
testng.run();
}
public static class LocalTestClass {
private String myParameterString;
@Parameters ({"myParameterString"})
@BeforeClass
public void setupTests(String myParameterString) {
this.myParameterString = myParameterString;
}
@Test
public void helloWorld() {
System.err.println("Hello there " + myParameterString);
}
}
}
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.
//Create an instance on TestNG
TestNG myTestNG = new TestNG();
//Create an instance of XML Suite and assign a name for it.
XmlSuite mySuite = new XmlSuite();
mySuite.setName("ASQA Sample Suite");
//Create an instance of XmlTest and assign a name for it.
XmlTest myTest = new XmlTest(mySuite);
myTest.setName("ASQA Sample Test");
//Add any parameters that you want to set to the Test.
myTest.addParameter("myParameterString", "value");
//Create a list which can contain the classes that you want to run.
List<XmlClass> myClasses = new ArrayList<XmlClass> ();
myClasses.add(new XmlClass("com.ibm.testing.LocalTestClass"));
//Assign that to the XmlTest Object created earlier.
myTest.setXmlClasses(myClasses);
//Create a list of XmlTests and add the Xmltest you created earlier to it.
List<XmlTest> myTests = new ArrayList<XmlTest>();
myTests.add(myTest);
//add the list of tests to your Suite.
mySuite.setTests(myTests);
//Add the suite to the list of suites.
List<XmlSuite> mySuites = new ArrayList<XmlSuite>();
mySuites.add(mySuite);
//Set the list of Suites to the testNG object you created earlier.
myTestNG.setXmlSuites(mySuites);
//invoke run() - this will run your class.
myTestNG.run();
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.
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.