TestNG提供两种程序调用的方式运行 1、直接创建testng对象,把class添加到testng对象中 - TestNG testng = new TestNG();
- testng.setTestClasses(new Class[] { demo.class });
- testng.run();
复制代码2、通过创建tesng.xml配置文件
- <suite name="TmpSuite" >
- <test name="TmpTest" >
- <classes>
- <class name="servers.testcase.Demo" />
- <class name="servers.testcase.LoginCase" />
- <classes>
- </test>
- </suite>
- XmlSuite suite = new XmlSuite();
- suite.setName("TmpSuite");
-
- XmlTest test = new XmlTest(suite);
- test.setName("TmpTest");
- List<XmlClass> classes = new ArrayList<XmlClass>();
- classes.add(new XmlClass("servers.testcase.Demo"));
- classes.add(new XmlClass("servers.testcase.LoginCase"));
- test.setXmlClasses(classes) ;
- List<XmlSuite> suites = new ArrayList<XmlSuite>();
- suites.add(suite);
- TestNG tng = new TestNG();
- tng.setXmlSuites(suites);
- tng.run();
复制代码
|