У меня есть следующий фрагмент кода:
try {
Properties properties = new Properties();
properties.load(Thread.currentThread().getContextClassLoader()
.getResourceAsStream("application.properties"));
String accessKey = properties.getProperty("");
String secretKey = properties.getProperty("");
return new BasicAWSCredentials(accessKey, secretKey);
} catch (FileNotFoundException io) {
log.error("Properties file not found.");
return null;
} catch (IOException io) {
log.error("Error loading property.");
return null;
} catch (IllegalArgumentException io) {
log.error("Access Key or Secret key not present/found");
return null;
}
в jUnit, я могу проверить и охватить для успеха, FileNotFoundException
и IllegalArgumentException
, но не могу покрыть и проверить для IOException
в этом случае.Я новичок в написании тестов.Я также пытался понять mockito, но не смог найти способ сделать это.