将@Factory
与@DataProvider
一起使用时遇到编译错误。
尝试将hashmap
映射到我的dataprovider
,并想先运行我的所有测试用例,然后再进行下一个testdata
行,因此尝试使用@Factory
HashMap < String, String testdata = new HashMap < String, String();
@Test
private void test_01() {
System.out.println(testdata.get("-some-hashmap-key-"));
}
@DataProvider
public static Object[][] getDataSet() {
int i = 0;
Object[][] dataSet = new Object[2][1];
HashMap < String, String > rowValuesMap = new HashMap();
for (-some logic - ) {
for (-some logic - ) {
dataSet[i][0] = rowValuesMap;
}
i++;
}
return dataSet;
}
@Factory(dataProvider = "getDataSet")
public MyTestFile(HashMap < String, String testdata) {
this.testdata = sheetdata;
}
答案 0 :(得分:0)
HashMap声明在所有地方都是错误的。试试这个
HashMap < String, String > testdata = new HashMap < String, String > ();
@Test
private void test_01() {
System.out.println(testdata.get("-some-hashmap-key-"));
}
@DataProvider
public static Object[][] getDataSet() {
int i = 0;
Object[][] dataSet = new Object[2][1];
HashMap < String, String > rowValuesMap = new HashMap < String, String > ();
for (-some logic - ) {
for (-some logic - ) {
dataSet[i][0] = rowValuesMap;
}
i++;
}
return dataSet;
}
@Factory(dataProvider = "getDataSet")
public MyTestFile(HashMap < String, String > testdata) {
this.testdata = sheetdata;
}