解决reportNG中文乱码(转:http://www.it610.com/article/3626590.htm)

Posted Uknow!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决reportNG中文乱码(转:http://www.it610.com/article/3626590.htm)相关的知识,希望对你有一定的参考价值。

1.下载reportng源码
     git clone  https://github.com/dwdyer/reportng.git
2.修改AbstractReporter.java
     package org.uncommons.reportng;
     ...
     import java.io.OutputStream;
     ...
     protected void generateFile(File file,
                                String templateName,
                                VelocityContext context) throws Exception
    {
        //Writer writer = new BufferedWriter(new FileWriter(file));
        //encoding to utf-8
        OutputStream out = new FileOutputStream(file);
        Writer writer = new BufferedWriter(new OutputStreamWriter(out,"utf-8"));
        try
        {
            Velocity.mergeTemplate(classpathPrefix + templateName,
                                   ENCODING,
                                   context,
                                   writer);
            writer.flush();
        }
        finally
        {
            writer.close();
        }
    }
3.编译源码
     cd reportng
     ant
 
PS:ant环境配置
1.下载ant源码包
      http://ant.apache.org/bindownload.cgi
2.解压到安装位置
     unzip to D:\apache-ant-1.9.6
3.修改环境变量
     set ANT_HOME      D:\apache-ant-1.9.6
     set Path                  %ANT_HOME%\bin
4.验证ant
     cmd:ant -version
技术分享

解决reportNG中文乱码

以上是关于解决reportNG中文乱码(转:http://www.it610.com/article/3626590.htm)的主要内容,如果未能解决你的问题,请参考以下文章

你好,请问eclipse里运行testNG case后,运行结果显示乱码,但console里显示是正常中文,谢谢!

关于reportng生成的测试报告不按测试执行顺序的解决办法

关于Mysql中文乱码问题该如何解决(乱码问题完美解决方案)(转)

理解并解决GBK转UTF-8奇数中文乱码(转)

解决linux服务器上matplotlib中文显示乱码问题

shp转geojson并解决属性丢失或属性中文乱码方法