使用数据提供程序我将数据从excel提取到类中,测试类包含多个@Test。所以现在我需要将数据提供程序中的所有参数传递给所有测试,而不是在测试中使用必需的参数。那么有什么方法可以声明共同的参数,以便在
上使用import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class TestSample extends Library {
@BeforeClass()
public void Setup() {
}
@Test(dataProvider = "dataSupplier", priority = 0)
public void Verify_Test1(String adminName, String adminPassword, String emailId, String emailId1, String emailId2, String emailId3, String deviceCountry, String firstName, String lastName, String phoneNo, String productName, String productName1, String productName2, String productName3) {
startAdminLogin(adminName, adminPassword);
try {
} finally {
adminHomePage.clickAdminLogout();
}
}
@Test(dataProvider = "dataSupplier",priority = 1)
public void Verify_Test2(String adminName, String adminPassword, String emailId, String emailId1, String emailId2, String emailId3, String deviceCountry, String firstName, String lastName, String phoneNo, String productName, String productName1, String productName2, String productName3) {
startAdminLogin(adminName, adminPassword);
try {
} finally {
adminHomePage.clickAdminLogout();
}
}
@Test(dataProvider = "dataSupplier",priority = 2)
public void Verify_Test3(String adminName, String adminPassword, String emailId, String emailId1, String emailId2, String emailId3, String deviceCountry, String firstName, String lastName, String phoneNo, String productName, String productName1, String productName2, String productName3) {
startAdminLogin(adminName, adminPassword);
try {
} finally {
adminHomePage.clickAdminLogout();
}
}
@DataProvider
public Object[][] dataSupplier() {
List<Object[]> list2 = ExcelHelper.getDataList("adminUsers");
List<Object[]> list3 = ExcelHelper.getDataList(“userDetails”);
return mergeListToArray(list2, list3);
}
}