Search code examples
mavenseleniumjunitmaven-surefire-plugin

maven-surefire-report-plugin does not build HTML report


I am trying to generate an HTML report from my JUnit Selenium test cases. I followed a few tutorials available online, which suggested me to use maven-surefire-report-plugin. After following a few tutorials when I try to integrate the same idea in my own project, it does not work for me.

My POM.xml follows:

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

I am new to this field, any help would be appreciated.


Solution

  • The call to the maven-surefire-report-plugin in the reporting section of the POM is missing. Please have a look at http://maven.apache.org/surefire/maven-surefire-report-plugin/usage.html