像这样的东西?如果不是,请澄清。
public static Collection<File> data() {
return Arrays.asList(new File("test_files").listFiles());
}
如果您必须在集合中包含数组,请尝试以下操作:
public static Collection<Object[]> data() {
return java.util.Collections.singleton((Object[])new File("test_files").listFiles());
}
编辑:再试一次:
public static Collection<Object[]> data() {
String[] fileNames = new File("test_files").list();
Object[] namesInObjectArray = new Object[fileNames.length];
for (int i = 0; i < fileNames.length; i++) {
namesInObjectArray[i] = "test_files/" + fileNames[i];
}
Object[][] outerObjectArray = new Object[][] { namesInObjectArray };
return Arrays.asList(outerObjectArray);
}