Encoding Jenkins和TestNG结果编码
我正在使用Jenkins构建我的Maven项目,并使用插件发布testng结果。报告中的西里尔字母符号有问题。它看起来像:��������. 但是 Jenkins控制台中的西里尔文输出正常 My pom.xml:Encoding Jenkins和TestNG结果编码,encoding,character-encoding,jenkins,testng,jenkins-plugins,Encoding,Character Encoding,Jenkins,Testng,Jenkins Plugins,我正在使用Jenkins构建我的Maven项目,并使用插件发布testng结果。报告中的西里尔字母符号有问题。它看起来像:��������. 但是 Jenkins控制台中的西里尔文输出正常 My pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>ru.ibs</groupId>
<artifactId>msprjtest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.32.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.googlecode</groupId>
<artifactId>maven-idea-plugin</artifactId>
<version>1.6.1</version>
<configuration>
<!--vmParameters>-Dfile.encofing=UTF-8</vmParameters-->
<compileInBackground>false</compileInBackground>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<reportsDirectory>${basedir}/test-output</reportsDirectory>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>maven-idea-plugin-repo</id>
<url>http://maven-idea-plugin.googlecode.com/svn/maven-repo</url>
</pluginRepository>
</pluginRepositories>
<!-- profiles -->
<profiles>
<profile>
<id>ie9</id>
<properties>
<env>local</env>
<user.username></user.username>
<user.password></user.password>
<grid2.hub></grid2.hub>
<site.url>http://msprjtest:6005/</site.url>
<browser.name>ie</browser.name>
<browser.version></browser.version>
<browser.platform></browser.platform>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</project>
UTF-8
4.0.0
ru.ibs
msprjtest
1.0-快照
罐子
org.testng
testng
6.8.5
朱尼特
朱尼特
4.11
org.seleniumhq.selenium
硒爪哇
2.32.0
com.opera
操作驾驶员
1.2
src/main/resources
真的
谷歌代码
maven创意插件
1.6.1
假的
org.apache.maven.plugins
maven资源插件
2.6
UTF-8
maven surefire插件
2.14.1
${basedir}/测试输出
src/test/resources/testng.xml
maven编译器插件
3.1
1.6
1.6
UTF-8
maven idea插件回购
http://maven-idea-plugin.googlecode.com/svn/maven-repo
ie9
地方的
http://msprjtest:6005/
即
真的
项目编码设置为UTF-8。IDE是Intellij IDEA 12.1.3。TestNG 6.8.5.实际上
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
...
<encoding>UTF-8</encoding>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea
-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
org.apache.maven.plugins
maven surefire插件
2.14.1
...
UTF-8
UTF-8
UTF-8
-Xms256m-Xmx512m-XX:MaxPermSize=128m-ea
-文件编码=UTF-8
应该会修复它。准确地说,报告文件(在./target/surefire reports/下的那些)或测试日志(这是您在终端中运行“mvn测试”时看到的)中的编码不好。./target/surefire reports/testng-results.xml Jenkins output console中的编码不好,如果我使用“mvn测试”编码也很糟糕。如果我使用testng.xml在pom.xml中使用encoding OK从IDEA运行测试,我会为project.build.sourceEncoding和maven资源及编译器插件设置UTF-8。但它对输出没有影响。我尝试重新创建一些最小的设置,但没有重现问题(ubuntu是我的设备,所以它是UTF-8)。您仍然可以查看已编译的测试类,以查看西里尔文消息是否正确编译。如果该类包含垃圾,则是编译器有罪,否则是运行者。在我的情况下,只要
-Dfile.encoding=UTF-8
就足够了