我正在使用 JUnit 参数化测试并出现此错误:
java.lang.IllegalArgumentException:参数数量错误
这是代码:
测试:
@Parameters
public static Collection<Object[]> spreadsheetData() throws IOException {
InputStream file = new FileInputStream("c:\\Path\\to\\file\\jeje.xls");
return Utils.loadFromExcel(file);
}
方法:
public static Collection<Object[]> loadFromExcel(final InputStream excelFile)
throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook(excelFile);
Sheet sheet = workbook.getSheetAt(0);
// Number of columns
int numberOfColumns = countNonEmptyColumns(sheet);
int rows=0;
// Number of rows
for (Row row : sheet) {
rows++;
}
Object[][] datos = new Object[numberOfColumns][rows];
for (int row = 0; row<rows; row++) {
for (int column = 0; column < numberOfColumns; column++) {
Cell cell = sheet.getRow(row).getCell(column);
datos[column][row] = cell.getRichStringCellValue();
}
}
return Arrays.asList(datos);
}
我不知道怎么了。
感谢您的帮助