I have the class TableCollection which creates tables for data store in the given direcoty, the method which reads this goes like this.
where dirname is the directory name and regex is a regular expression which allows the read method to only take files in that directory which matches that expression.
On my JUnit testing I have the following test:
The test tests whether the path or directory is valid or not
On my read method must I include statements which firsts check whether the path in valid or not and throws an exception?
Code:
public void read(String dirname,String regex) throws IOException{
On my JUnit testing I have the following test:
The test tests whether the path or directory is valid or not
Code:
@Test //2
public void testPathInvalid() throws IOException {
TableCollection all = new TableCollection();
try {
all.read("junk/file","");
}
catch
(FileNotFoundException e) {
return;
}
fail("FileNotFoundException expected");
}
//This returns the following error
java.lang.NullPointerException from line:61 i.e all.read("junk/file","");
Comment