The method funcB() should throw the exception, not catch it. The code bellow and test work fine:
public class FileClass {
public void funcB() throws ClassNotFoundException {
//try {
throw new ClassNotFoundException();
//} catch ( ClassNotFoundException e) {
//}
}
}
Mockito test:
public class TestFileClass {
@Test(expected = ClassNotFoundException.class)
public void testFuncB() throws ClassNotFoundException {
FileClass fc = Mockito.spy(new FileClass());
fc.funcB();
}
}