TestNG中同一个类中执行多个test()方法如何配置testng.xml

 

public class IndexInfo extends BaseTesting{
private IndexPage IndexPage1;
// private AddEquipmentInfoManagePage AddEquipmentInfoManagePage1;

protected static final Log log = LogFactory.getLog(IndexPage.class);
@BeforeClass
public void beforeClass() throws Exception {
init(Constants.USER_ADMIN, Constants.PASSWD_ADMIN);
IndexPage1=new IndexPage(driver);
}

@AfterTest
public static void tearDownAfterClass() throws Exception {
if(driver != null)
{
driver.quit();
System.out.println("运行结束");

}
}
@Test(dataProvider = "csvtestLogin1")
public void testLogin1(String case_num,String username,String password,String msg,String info) throws InterruptedException{
{

System.out.println("方法1");


}

@Test(dataProvider = "csvtestLogin2")
public void testLogin2(String case_num,String username,String password,String msg,String info) throws InterruptedException{
{

System.out.println("方法2");


}

 

 

配置testng.xml文件;

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">
  <test name="Demo"  >
    <classes>
      <class name="com.sa.test.IndexInfo">
          <methods preserve-order="true">
              <include name="testLogin1"/>
              <include name="testLogin2"/>          
          </methods>
      </class>
    </classes>
  </test>
</suite>

 

你可能感兴趣的:(TestNG)