maven-surefire-report-plugin不构建HTML报告

时间:2014-06-23 09:17:17

标签: maven selenium junit maven-surefire-plugin

我正在尝试从我的JUnit Selenium测试用例生成HTML报告。我在网上提供了一些教程,建议我使用maven-surefire-report-plugin。在我尝试将相同的想法集成到我自己的项目中之后,按照一些教程后,它对我不起作用。

我的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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>TestJUnit</groupId>
  <artifactId>TestJUnit</artifactId>
  <version>0.0.1-SNAPSHOT</version>

 <dependencies>
  <dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.11</version>
  <type>jar</type>

 </dependency>
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>2.41.0</version>
</dependency>
<dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.5</version>
</dependency>
<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1</version>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.13</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.10-FINAL</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.10-FINAL</version>
</dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>2.41.0</version>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.3</version>
    </dependency>
     <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.5</version>
        <type>maven-plugin</type>
    </dependency>
    <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-junit</artifactId>
            <version>1.8.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-trax</artifactId>
            <version>1.8.0</version>
        </dependency>
  </dependencies>
  <build>

  <sourceDirectory>src</sourceDirectory>
<plugins>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>


      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <includes>
            <include>harness.java</include>
          </includes>
        </configuration>
      </plugin>    


<plugin>
    <groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
    <artifactId>maven-antrun-extended-plugin</artifactId>
    <executions>
        <execution>
            <id>test-reports</id>
            <phase>run</phase>
            <configuration>
                <tasks>
                    <junitreport todir="target/surefire-reports">
                        <fileset dir="target/surefire-reports">
                            <include name="**/*.xml">
                        </include></fileset>
                        <report format="noframes" todir="target/surefire-reports">
                    </report></junitreport>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
 </plugin>


</plugins>

</build>
</project>

我是这个领域的新手,任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

缺少对POM maven-surefire-report-plugin部分中reporting的调用。请查看http://maven.apache.org/surefire/maven-surefire-report-plugin/usage.html