为testNG框架下的项目添加main方法,一键运行所有xml下的测试用例
有了main方法,不仅可以一键运行所有xml下的测试用例,还能打包测试用例为jar 文件,在别的电脑上直接运行和使用了。
public class Main { public static void main(String args[]) { TestNG tng = new TestNG(); List<String> suites = phase1(); tng.setTestSuites(suites); tng.run(); } public static List<String> phase1(){ List<String> suites = new ArrayList<String>(); String rootPath = System.getProperty("user.dir"); suites.add("fakepath\\FakeTestCase1.xml");//path to xml.. suites.add("fakepath\\FakeTestCase2.xml"); suites.add("fakepath\\FakeTestCase3.xml"); suites.add("fakepath\\FakeTestCase4.xml"); suites.add("fackpath\\FakeTestCase5.xml"); return suites; }