It is often useful to show the results of our tests to others people who are not developers, like managers or executive. This tutorial shows how to integrate a Cucumber reporting a Java plugin in Maven project. The result is a simple web page, which does not require a special tool to be read.
EDIT: this post is deprecated. There is a better version of Cucumber Report plugin, without jars to download. Please read the new post here:
https://damienfremont.com/2016/05/09/how-to-cucumber-test-report-plugin-2-with-maven-and-java/
This tutorial will cover 3 reports plugins : JSON, HTML Pretty and HTML Reports.
Native JSON Result
How to:
pom.xml
4.0.0 com.damienfremont.blog 20150730-test-cucumber_plugin_reporting 0.0.1-SNAPSHOT jar junit junit 4.12 test info.cukes cucumber-junit 1.2.3 test info.cukes cucumber-java8 1.2.3 test
RunBDDTest.java
@RunWith(Cucumber.class) @CucumberOptions(strict = false, features = "features", format = { "pretty", "json:target/cucumber.json" }, tags = { "~@ignore" }) public class RunBDDTest { }
Demo:
Launch with JUnit or
>mvn test
The result is at /target/cucumber.json
Native HTML Plugin
How to:
RunBDDTest.java
@RunWith(Cucumber.class) @CucumberOptions(strict = false, features = "features", format = { "pretty", "html:target/site/cucumber-pretty", "json:target/cucumber.json" }, tags = { "~@ignore" }) public class RunBDDTest { }
Demo:
Launch with JUnit or
>mvn test
The result is at /target/site/cucumber-pretty/index.html
Cucumber-Reports HTML Plugin
How to:
pom.xml
4.0.0 com.damienfremont.blog 20150730-test-cucumber_plugin_reporting 0.0.1-SNAPSHOT jar junit junit 4.12 test info.cukes cucumber-junit 1.2.3 test info.cukes cucumber-java8 1.2.3 test <!-- REPORTING --> com.googlecode.totallylazy totallylazy 1.20 system ${project.basedir}/lib/totallylazy-1.20.jar net.masterthought cucumber-reporting 0.0.24 org.apache.maven.plugins maven-compiler-plugin 3.3 1.8 1.8 org.apache.maven.plugins maven-surefire-plugin 2.18.1 true **/*BDDTest.java net.masterthought maven-cucumber-reporting 0.0.5 com.googlecode.totallylazy totallylazy 991 system ${project.basedir}/lib/totallylazy-991.jar execution verify generate cucumber-jvm-example ${project.build.directory}/site/cucumber-reports ${project.build.directory}/cucumber.json false true
And two libs (external to Maven repositories)
https://code.google.com/p/totallylazy/downloads/list
RunBDDTest.java
@RunWith(Cucumber.class) @CucumberOptions(strict = false, features = "features", format = { "pretty", "html:target/site/cucumber-pretty", "json:target/cucumber.json" }, tags = { "~@ignore" }) public class RunBDDTest { }
Demo:
Launch with
mvn clean install
The result is at /target/site/cucumber-reports/feature-overview.html
Conclusion
JSON is OK for integration with other tools (jenkins plugin, reports, etc).
Pretty HTML is OK during development phase (like a JUnit or Surefire report for versionning).
Cucumber-Reports is good for reporting outside of the dev team (like managers).
Source
https://github.com/DamienFremont/blog/tree/master/20150730-test-cucumber_plugin_reporting
References
https://cucumber.io/docs/reference/jvm
[…] https://damienfremont.com/2015/07/30/how-to-cucumber-test-reporting-plugin-with-maven-and-java/ […]
This does not work for me. Surely I m missing something.
the same is not work for me, please do update me if anyone have implemented successfully.
this post is deprecated. There is a better version of Cucumber Report plugin, without jars to download. Please read the new post here:
https://damienfremont.com/2016/05/09/how-to-cucumber-test-report-plugin-2-with-maven-and-java/
What is the reason for using the jars externally to maven?
This would violate lots of corporate “security” / “standards” in the corporate domain (“too big to do things …”)
Because some of these jars are not in maven repositories. The plugin developpers have made clear that it will not be the case in the near futur : -(
Thanks…
I am using in my project a product from ExtentReports by relevantcodes
Ever tried it?
It is quite nice…
Can you please provide more information on how to integrate cucumber with extent reports
Can we apply this same solution to testng with cucumber-jvm. I tried it but didn’t work.
I am also looking for this report with TestNG implementation,
Also do we have this plugin available for Gradle?
Finally I am able to generate this masterthought report with testng and maven.
Do we need to do any specific setting/process for Report when using TestNG?
I have uploaded my code on github https://github.com/sahajamit/Maven-Failsafe-Plugin-Example
Please let me know in case of any questions.
i am stuck to generated the feature over view file.
kenwal, did you get any answer for your que? because I too have same que
Hi Amit can u share that piece of code for generating reports detailed one like how many no.of test cases passed or failed ?
You can refer this repo which I have created on Github.
https://github.com/sahajamit/cucumber-jvm-testng-integration/blob/master/src/test/java/com/cucumber/testng/examples/GenerateReport.java
sahajamit.github.io
Your repo has good example Amit, Thanks for sharing. I will try it soon and update you.
Thanks,
[…] and third party plugins to execute cucumber reports and stats for tests: 1. https://damienfremont.com/2015/07/30/how-to-cucumber-test-reporting-plugin-with-maven-and-java/ […]
EDIT: this post is deprecated. There is a better version of Cucumber Report plugin, without jars to download. Please read the new post here:
How to Cucumber : Test Report Plugin 2 with Maven and Java
Please do let me know where i can donwload these jar, Project dont have jar files. please do update me
this post is deprecated. There is a better version of Cucumber Report plugin, without jars to download. Please read the new post here:
https://damienfremont.com/2016/05/09/how-to-cucumber-test-report-plugin-2-with-maven-and-java/
Good Example
[…] Honestly, I could not highlight best reporting way for today with ExtentReports, hopefully, they will resolve existing problems. Please note that there are many not so fancy reporting engines for your Java + Cucumber tests (example: https://damienfremont.com/2015/07/30/how-to-cucumber-test-reporting-plugin-with-maven-and-java/). […]
Hello, in the cucumber report in jenkins usually we can see the feature and if you click on a certain feature you will see the sceanrios. Is there a possibility to set futher category before feature in the cucumber reports? Example: two cars BMW ( feature = fix bmw) and audi (feature = fix audi). The reports in jenkins Im looking for are : BMW -> Feature -> scenario ->steps, audi-> feaure -> scenario-> steps