解決方案如下:
1.下載reportng源碼 https://github.com/dwdyer/reportng.git
2.修改AbstractReporter.java並保存,記得一定要導入OutputStream類。
OutputStream out = new FileOutputStream(file);
Writer writer = new BufferedWriter(new OutputStreamWriter(out,"utf-8"));
3.因爲該項目打包用的是ant,所以需要配置ant環境
1).下載ant源碼包 http://ant.apache.org/bindownload.cgi
2).解壓到安裝位置,如D:\apache-ant-1.9.6
3).進入計算機--屬性--高級系統配置--高級--環境變量--修改環境變量
系統環境變量中新增ANT_HOME,值爲:D:\apache-ant-1.9.6,修改path變量,
追加值:%ANT_HOME%\bin
4).驗證ant, cmd:ant –version
5).進入到項目的根目錄,並執行ant
6).進入到項目的dist目錄下,查看新打的包爲:reportng-1.1.5.jar,依賴包爲:velocity-dep-1.4.jar
7).找到當前使用reportng要生成報告的項目,依賴包所在位置,
一般在:C:\Users\用戶名\.m2\repository\org\uncommons\reportng下
在該目錄下新增1.1.5的文件夾,並將上述生成的包reportng-1.1.5.jar複製到該文件夾下。
8).在當前使用reportng要生成報告的項目的pom.xml文件中修改reportng的版本爲1.1.5,並引用其依賴包:velocity
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<!--reportng1.1.5依賴包-->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
9).重新執行maven test命令。查看report-output下生成的測試報告顯示