我创建了一个 Maven 项目,该项目涉及在完成时“写出”一个 CSV 文件。
我创建了一个测试类来生成一个“模拟/测试”报告文件,但是在运行我的单元测试时,当使用“mvn package”或“mvn test”命令时,我得到这个错误:
28 Jan 2012 11:17:51,499 main DEBUG main.executors.ReportsExecutor:111 - Finished processing documents in 0.0 hours
28 Jan 2012 11:17:51,516 main ERROR main.utilities.FileWriterObject:279 - writeToADelimitedFile: reports/reportResults_1_28_2012_11.17.515.csv (No such file or directory) APPEND VALUE: false
28 Jan 2012 11:17:51,517 main ERROR main.executors.ReportsExecutor:170 - java.io.FileNotFoundException: reports/reportResults_1_28_2012_11.17.515.csv (No such file or directory)
java.io.FileNotFoundException: reports/reportResults_1_28_2012_11.17.515.csv (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
at java.io.FileWriter.<init>(FileWriter.java:61)
at
请记住,“APPEND VALUE: false”输出只是一个调试语句,让我知道 FileWriter 构造函数中的“append”布尔参数为 false,以便“创建”具有相应文件名的新文件。
现在,在生产中,它工作得很好。只是我的单元测试不起作用。是否有一些我没有配置的“根测试”目录?
我对Maven很陌生。非常感谢任何反馈!