I'm having difficult time figuring out how to test a directory that I've made myself and imported in the Project Files.
Currently I have:
File file = new File(ExplorerView.class.getResource("/ExplorerViewTestFolder"));
Which I'm trying grab from here to test
ExplorerView explorer = new ExplorerView();
explorer.countFilesAndFolders("/ExplorerViewTestFolder");
Edit2: Changed to
public class ExplorerViewTests {
@Test
public void testCountFilesAndFolders() {
ExplorerView explorer = new ExplorerView();
explorer.countFilesAndFolders("/ExplorerViewTestFolder");
}
EDIT4:
public int countFilesAndFolders(File f) {
if (f.isFile()) {
return 1;
} else {
int total = 0;
for (File file : f.listFiles()) {
if (file.isHidden() == false) {
total += countFilesAndFolders(file);
}
}
return total + 1;
}
}