1、如果需要加入一个一个的类
public static void main(String args[]){
TestNG tng = new TestNG();
tng.SetTestClasses(new Class[]{MyTest.class}) //这里可以加多个类。
tng.run();
}
2、如果已经写好了测试套件XML可以使用以下方式
public static void main(String args[]){
TestNG tng = new TestNG();
RetryTestListener rtl = new RetryTestListener();
XmlSuite xs = new XmlSuite();
Parser parser = new Parser("./testxml/temp.xml");
List<XmlSuite> suites = new ArrayList<XmlSuite>();
try {
suites = parser.parseToList();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
tng.setXmlSuites(suites);
tng.addListener(rtl);
tng.run();
}
本文详细介绍了如何使用TestNG框架进行自动化测试,包括如何添加多个测试类到测试套件,以及如何通过解析XML配置文件来运行已定义的测试套件。此外,还展示了如何使用RetryTestListener来处理测试失败后的重试机制。
827

被折叠的 条评论
为什么被折叠?



