我有一些WebdriverSelenium / TestNG / Maven / Java持续集成测试,我重构了(删除了一大堆遗产),现在我也安装了Spring DI框架。
我不能将参数传递给Test方法(oneUserTwoUser)
这是数据提供者
public class AppData {
public static WebDriver driver;
public static WebDriverWait wait;
final static String FILE_PATH = "src/test/resources/250.csv";
final static String FILE_PATH2 = "src/test/resources/places.csv";
public static ArrayList<ArrayList<String>> array;
public static Object[][] setUp() throws Exception {
//prepare data
//read data from CSV files
array = getCSVContent(FILE_PATH, 5);
array2 = getCSVContent(FILE_PATH2, 7);
//pass the data to the test case
Object[][] setUp = new Object[1][3];
setUp[0][0] = driver;
setUp[0][1] = wait;
setUp[0][2] = array;
return setUp;
}
这是测试类:
公共类AppTest3 {
public static AppData appdata;
public static void main (String[] args) {
BeanFactory beanfactory = new XmlBeanFactory(new FileSystemResource("spring.xml"));
appdata = (AppData) beanfactory.getBean("data");
}
@Parameters({ "driver", "wait", "array" })
@Factory(dataProviderClass = AppData.class, dataProvider = "setUp")
@Test
public void oneUserTwoUser(WebDriver driver, WebDriverWait wait, ArrayList<ArrayList<String>> array) throws Exception {
错误
org.testng.TestNGException:
Parameter 'driver' is required by @Test on method oneUserTwoUser but has not been marked @Optional or defined
答案 0 :(得分:1)
使用@DataProvider(name="standardTestData")
然后删除除@Test(dataProvider="standardTestData", dataProviderClass=AppData.class)