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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM