top of page
Search

How to generate a Maven Cucumber Report in 2024

Updated: Nov 8, 2023

Simran Raina @sraina / 06.30 PM EDT. July 19, 2023.

Maven Cucumber reporting has gone viral and why not. It provides very cool and pretty reports for the BDD framework. You can integrate the dependency provided by master thought and generate cool reports for your BDD tests. These reports can look like extent reports but on a second look are more elaborate.


Check out our Automation Testing course offerings to learn more from me in a live classroom environment.


Here we will talk about the details of dependencies required to launch Maven Cucumber Reporting for test automation. There are different types of automation reports such as TestNG, Junit, default HTML and pretty HTML format. Maven cucumber reports are far preferred for the following reasons:


1. The report is more elaborate compared to any other report. It is, on its own, enough to give more information about the execution of the test, to management of the test and has various information for several levels of stakeholders.

2. The report looks pretty and also prints missing steps in a test.

3. It is best suited for any test framework and especially complements the BDD Cucumber framework.


So, let's get started with an example. The steps listed below will assist you in running your own cucumber reports in no time.


Setup your pom.xml:


Add the code below to your pom.xml file:


<dependency>         
      <groupId>net.masterthought</groupId>        
      <artifactId>cucumber-reporting</artifactId>                     
      <version>5.6.1</version>      
</dependency>

in your pom.xml file, update the plugin section with the code below:


<plugin>
   <groupId>net.masterthought</groupId>
   <artifactId>maven-cucumber-reporting</artifactId>
   <version>5.6.0</version>
   <executions>
     <execution>
	<id>execution</id>
	<phase>verify</phase>
	<goals>
	    <goal>generate</goal>
	</goals>
	<configuration>		
	<projectName>cucumberReporting</projectName>    
        <skip>false</skip>		
        <outputDirectory>${project.build.directory}</outputDirectory>	     
        <inputDirectory>${project.build.directory}</inputDirectory>
        <jsonFiles>
          <param>**/*.json</param>
        </jsonFiles>	
        <mergeFeaturesById>false</mergeFeaturesById>
        <mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
        <checkBuildResult>false</checkBuildResult>		    			  
        </configuration>
   </execution>
  </executions>
</plugin>

The plugin section will require input as a JSON report created from the Cucumber JUnit test. We will have Cukerunner.java run our Cucumber test.


The output of the plugin will be the Maven Cucumber report generated in the \target\cucumber-html-reports folder with the name:

report-feature_xxxxxxx.html


After the plugin update, we need to run the Cucumber feature as a JUnit test from Cukerunner.java file. This will generate a .json file that will be utilized by the Maven Cucumber report to get information about the test execution.


Then we need to open pom.xml,

right-click and

Run As -> maven build as shown in the image:









In the Configuration window, we have to give Goals as verify and Run. Ensure build is successful.







Code can be downloaded from the BusyQA GitHub repository -> https://github.com/busyqaautomation/CucumberMavenReporting

Once build is successful, check the \target\cucumber-html-reports\report-feature_xxxxxxx.html to view your report. You can check out the report snippets below. And there you have it, your first Maven Cucumber Report.






At BusyQA, we have courses that will teach you this reporting skill and many more that will make you a good Automation Test Engineer in 2023. We have designed a flexible and easy-to-learn curriculum with an in-house coop program that has launched the careers of many Automation and Software Testing Engineers.









Comments


bottom of page