背景
執行完用例查看報告,發現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>
|