我正在尝试创建一个起始点类,它将生成一个testng.xml
,然后启动所有测试用例。
package trigger;
import java.util.ArrayList;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;
import com.beust.testng.TestNG;
public class StartTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
XmlSuite suite1 = new XmlSuite();
suite1.setName("S1");
XmlTest t1 = new XmlTest(suite1);
t1.setName("Test1");
XmlClass c1 = new XmlClass("testcases.TC_MMI_001");
XmlClass c2 = new XmlClass("testcases.TC_MMI_002");
XmlClass c3 = new XmlClass("testcases.TC_MMI_003");
ArrayList<XmlClass> ac = new ArrayList<XmlClass>();
ac.add(c1);
ac.add(c2);
ac.add(c3);
t1.setXmlClasses(ac);
ArrayList<XmlTest> at= new ArrayList<XmlTest>();
at.add(t1);
suite1.setTests(at);
ArrayList<XmlSuite> as = new ArrayList<XmlSuite>();
as.add(suite1);
TestNG tng = new TestNG();
tng.setXmlSuites(as);
tng.run();
}
}
是否有另一种方法可以在TestNG