testng-result中文乱码问题

背景

执行完用例查看报告,发现testng-result.xml文件中关于中文的都是乱码

 

解决方法

eclipse已设置了utf-8去编译,所以直接运行run as testng ,在console栏输出中文是没有问题的

通过mvn去执行的时候用的是maven-surefire-plugin插件,所以需要修改这里新增

<argLine>-Dfile.encoding=UTF-8</argLine> 

 

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>
                        -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar -Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter"
                    </argLine>
                    <argLine>-Dfile.encoding=UTF-8</argLine>   
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
posted @ 2017-06-24 13:49  whendream  阅读(2363)  评论(4编辑  收藏  举报