Jenkins和TestNG结果编码 [英] Jenkins and TestNG results encoding

查看:142
本文介绍了Jenkins和TestNG结果编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Jenkins构建我的Maven项目,并使用插件发布测试结果。报告中有西里尔字符的问题。看起来像: 。但是Jenkins控制台的
cyrillic输出是可以的。



我的pom.xml:

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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\">
<属性>
< 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>
<依赖关系>
<依赖关系>
< groupId> org.testng< / groupId>
< artifactId> testng< / artifactId>
< version> 6.8.5< / version>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 4.11< / version>
< / dependency>
<依赖关系>
< groupId> org.seleniumhq.selenium< / groupId>
< artifactId> selenium-java< / artifactId>
< version> 2.32.0< / version>
< / 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>
<! - 个人资料 - >
<个人资料>
<个人资料>
< id> ie9< / id>
<属性>
< 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>
< activate>
< activeByDefault> true< / activeByDefault>
< / activation>
< / profile>
< / profiles>
< / project>

项目编码设置为UTF-8。 IDE是Intellij IDEA 12.1.3。 TestNG 6.8.5。

解决方案

其实,

 <插件> 
< 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>

应该修复它。


I am use Jenkins to build my Maven project and post testng results using plugin. Have a problem with cyrillic symbols in report. It's look like: ��������. But cyrillic output in Jenkins console is OK.

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.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>

Project encoding is set to UTF-8. IDE is Intellij IDEA 12.1.3. TestNG 6.8.5.

解决方案

Actually,

<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>

Should fix it.

这篇关于Jenkins和TestNG结果编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆