【发布时间】:2019-04-25 10:22:13
【问题描述】:
我在将对象传递给 Testng 数据提供者时遇到了问题。
主要问题: 我正在使用https://github.com/ozlerhakan/poiji 从 Excel 文件中读取测试数据(1 行是 Person 类的 1 个新对象)。
它返回一个 Person 对象列表,但对于数据提供者,它应该是 Object[][]。如何转换?
Xlsx 文件:
firstName | secondName
-----------------------
John | Deer
Eric | Boots
人物类:
public class Person{
@ExcelCellName("firstName")
private String firstName;
@ExcelCellName("secondName")
private String secondName;
数据提供者:
@DataProvider
public Object[][] readExcel() throws Exception {
List<PersonalApplicant> res = Poiji.fromExcel(new File(("persons.xlsx")), Person.class);
return res;
}
错误:
Incompatible types.
Required:
java.lang.Object[][]
Found:
java.util.List
<com.example.package.Person>
【问题讨论】: