我是 Java 中 Junit 和 Mockito 测试的新手,有人可以给我一个示例或想法,说明我如何测试一个基本上读取路由和文件并接收日期作为参数的方法:
public String getFileAE(String fecha) {
String fileName = null;
String filePath = null;
File file = null;
try {
logger.info("Leyendo archivo ejecutivos facultados");
fileName = ConstantsFiles.FILE_NAME_AE + fecha + ConstantsFiles.FILE_EXTENSION;
filePath = ConstantsFiles.FILE_PATH_AE + fileName;
logger.info(filePath);
file = new File(filePath);
if (!file.exists()) {
logger.error("Error, el archivo no existe: " + filePath);
return "";
}
return filePath;
} catch (Exception ex) {
logger.error("Error, el archivo no se pudo leer: " + ex.getMessage(), ex);
}
return filePath;
}