Maven + ReportNG + Jenkins +命令行

时间:2014-07-01 10:13:10

标签: maven jenkins reportng

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

之后使用Jenkins的插件HTML Reporter在Jenkins上插入报告。

我想这样做是因为当我把听众放在测试中时我遇到了错误。

我用它来执行Jenkins的测试:

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

我尝试使用mvn install但是我收到同样的错误

由于

编辑:所以我终于设法修复了我的POM文件,问题是有一些插件没有像velocity,reportng和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>

1 个答案:

答案 0 :(得分:0)

根据错误消息:

  

构建有效模型时遇到了一些问题   forselenium.simple:硒的简单的jar:0.0.1 - 快照       [警告]&#39; build.plugins.plugin.version&#39;对于org.apache.maven.plugins:缺少maven-surefire-plugin。 @第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后,听众的问题就会消失。

BTW:为什么不使用最新版本的maven-resources-plugin(2.6)和testng(6.8.7)..