Search code examples
eclipsemavenseleniumcucumbercucumber-jvm

Maven cucumber reporting from eclipse not generating the reports as per this plugin


Trying to generate the reports as per the maven cucumber reporting Link to maven cucumber reporting

Made the necessary changes in the pom.xml file as explained here tutorial on configuring reports

But the reports are getting generated in the simple html file but not as per the cucumber reports.

pom.xml

   <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.${java.version}</source>
                        <target>1.${java.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.20</version>
                    <configuration>
                        <!-- <testFailureIgnore>true</testFailureIgnore> -->
                        <includes>
                            <exclude>**/*RunCukesTest.java</exclude>
                            <!-- <include>**/*RunCukesTest.java</include> -->
                        </includes>
                        <!-- <excludes> <exclude>**/*RunCukesTest.java</exclude> </excludes> -->
                    </configuration>
                </plugin>
                <!-- This is for Cucumber Custom Report plug in we specify the configuration 
                    details under configuration tag. -->
                <!-- http://startingwithseleniumwebdriver.blogspot.com/2016/05/custom-cucumber-reporting-using-maven.html -->
                 <plugin>
                    <groupId>net.masterthought</groupId>
                    <artifactId>maven-cucumber-reporting</artifactId>
                    <version>3.11.0</version>
                    <executions>
                        <execution>
                            <id>execution</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <projectName>CucumberReport</projectName>
                                <outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
                                <!-- <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput> -->
                                <jsonFiles>
                                    <param>${project.build.directory}/cucumber.json</param>
                                </jsonFiles>
                                <!-- <parallelTesting>false</parallelTesting> -->
                                <buildNumber>1</buildNumber>
                                <checkBuildResult>false</checkBuildResult>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

RunCukesTest.java

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"classpath:features"},
        plugin = {"html:target/site/cucumber-pretty","json:target/cucumber.json"},
        tags = {"@currentTest"},
        glue={"helpers","stepDefinitions"},
        monochrome = true
        )
public class RunCukesTest{

}

Reports are generated like this generated report

which are different from expected expected report


Solution

  • all configuration was good, made two changes.

    1. removed pluginManagement tag in pom
    2. Used cucumberOutput output directory instead of jsonFiles. For some reason jsonFiles was generating duplicate reports.

    pom file,

          <build>
           <plugins>
              <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>3.3</version>
                 <configuration>
                    <source>1.${java.version}</source>
                    <target>1.${java.version}</target>
                 </configuration>
              </plugin>
              <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>2.20</version>
                 <configuration>
                    <includes>
                       <exclude>**/*RunCukesTest.java</exclude>
                    </includes>
                    <testFailureIgnore>true</testFailureIgnore>
                 </configuration>
              </plugin>
              <plugin>
                 <groupId>net.masterthought</groupId>
                 <artifactId>maven-cucumber-reporting</artifactId>
                 <version>3.13.0</version>
                 <executions>
                    <execution>
                       <id>execution</id>
                       <phase>verify</phase>
                       <goals>
                          <goal>generate</goal>
                       </goals>
                       <configuration>
                          <projectName>Simplify360 Automation Test Report</projectName>
                          <outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>                      
       <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                          <buildNumber>8.4.1.2</buildNumber>
                       </configuration>
                    </execution>
                 </executions>
              </plugin>
           </plugins>
        </build>