I have a simple class that writes data to a CSV file:
public class CsvFileWriter {
private static Logger logger = LogManager.getLogger();
public static void writeDataToCsvFile(String filePath, List<String[]> data) {
File file = new File(filePath);
try (FileWriter outputFile = new FileWriter(file)) {
CSVWriter writer = new CSVWriter(outputFile, ' ',
CSVWriter.NO_QUOTE_CHARACTER,
CSVWriter.DEFAULT_ESCAPE_CHARACTER,
CSVWriter.DEFAULT_LINE_END);
writer.writeAll(data);
} catch (IOException e) {
logger.error("Unable to find the specified path", e);
throw new ProjectException(e);
}
}
}
I would like to know how to test the method contained in this class. I found information that this can be done using Mockito. Is it so? and how can i do this?
Aucun commentaire:
Enregistrer un commentaire