【问题标题】:Maven+ReportNG+Jenkins+Command LineMaven+ReportNG+Jenkins+命令行
【发布时间】:2014-07-01 10:13:10
【问题描述】:

我想知道如何运行使用 maven 构建的测试以生成报告,然后使用命令行将报告转换为 ReportNG 格式。

之后使用来自 Jenkins 的 HTML Reporter 插件插入关于 Jenkins 的报告。

我想这样做是因为我在测试监听器时遇到了错误。

我正在使用它来执行 Jenkins 的测试:

    mvn test (after using "mvn clean install" on first time)

我尝试使用 mvn install 但我得到了同样的错误

谢谢

编辑:所以我终于设法修复了我的 POM 文件,问题在于一些未指定的插件,例如速度、报告和 guice。无论如何,我会把我的 POM 留在这里,这样它可以帮助其他人 =)

    <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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>selenium.simple</groupId>
    <artifactId>selenium-simple</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>selenium-simple</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
        <dependencies>
            <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>6.8.7</version>
            </dependency>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>2.24.1</version>
            </dependency>
            <dependency>
                <groupId>net.sf.opencsv</groupId>
                <artifactId>opencsv</artifactId>
                <version>2.3</version>
            </dependency>
            <dependency>
                <groupId>org.uncommons</groupId>
                <artifactId>reportng</artifactId>
                <version>1.1.2</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>velocity</groupId>
                <artifactId>velocity-dep</artifactId>
                <version>1.4</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
                <version>3.0</version>
                <scope>test</scope>
        </dependency>
        </dependencies>
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.6</version>                
                    <configuration>
                        <!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.17</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                        </suiteXmlFiles>
                        <systemPropertyVariables>
                            <webdriver.ie.driver>src/main/resources/drivers/internetexplorer/iedriverserver_2.24.1_x64.exe</webdriver.ie.driver>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>

【问题讨论】:

  • pom.xml的相关部分贴出来怎么样?
  • POM 文件添加到帖子

标签: maven jenkins reportng


【解决方案1】:

根据错误信息:

在构建有效模型时遇到了一些问题 forselenium.simple:selenium-simple:jar:0.0.1-SNAPSHOT [警告] org.apache.maven.plugins:maven-surefire-plugin 的“build.plugins.plugin.version”缺失。 @ 第 43 行, 第 12 栏

您应该像下面这样固定 maven-surefire-plugin 的版本:

<build>
  <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-surefire-plugin</artifactId>
       <version>2.17</version>
       ...
     </plugin>
  </plugins>
..
</build>

如果不这样做,您将使用可能太旧的旧版本 (maven-surefire-plugin:2.10)。我假设在你将版本放入你的 pom 之后,监听器的问题就会消失。

顺便说一句:为什么不使用最新版本的 maven-resources-plugin (2.6) 和 testng (6.8.7)..

【讨论】:

  • 第一行警告消失了,这很好,我只将版本从 2.17 更改为 2.10 我正在使用这些版本,因为是客户想要使用的版本...
  • 如果您坚持使用旧版本,这可能会导致您的问题。如果可行,我建议使用新版本进行测试。
  • 我更新了你建议的所有版本,maven-resources-plugin & testng,但我仍然遇到同样的错误
  • 根据您的更改,它看起来不像:maven-surefire-plugin:&lt;version&gt;2.10&lt;/version&gt;
  • 更改后代码不编译。这就是为什么我首先坚持使用 2.10...我更改了错误和 POM 代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-01
  • 2017-04-18
  • 1970-01-01
  • 2014-01-11
相关资源
最近更新 更多