This was the one long pending post that I wanted to share with you all. I would like to share my happiness that my first open source java library got published in Apache Maven to generate the custom report for Cucumber using Extent report.
My main goal was to create a custom report for the cucumber-jvm. But I don’t want to invest time in reinventing or developing htmls. I was searching for the library which can easily produce me the nice report with more details.
Then I found the ExtentReports authored by Anshoo Arora. There are many posts covering on how to use this library in your TestNG tests as a listener. However we always missed on how to use this in cucumber-jvm. Hence the cucumber-extentsreport library evolved. Let’s see the action part before you think I’m boring you.
I’ve created a new page for updates about this plugin. Kindly refer the page on how to use this library here: Cucumber Extent Reporter.
hi Vimal,
Great plugin..have been waiting for this. Just wanted to know if there is a possibility of taking screen shot and attaching it to step on failure, adding logging description of scenario and feature file and information on scenario.
Please suggest if there is any method available to add these onto the report.
Thanks and regards,
Karthik
Hey,
Got it.. I just had to specify the scenario description and feature description after the” Fearture:” and “Scenario:”
Glad you found the solution.
I am getting the below error:
cucumber.runtime.CucumberException: Couldn’t load plugin class: com.cucumber.listener.ExtentCucumberFormatter
Shami: Kindly provide me more information. The runner class would be more helpful to me. If possible, pom.xml also.
I’m facing same problem as Shami above. Here is my runner class below:
import java.io.File;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import com.cucumber.listener.ExtentCucumberFormatter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features={“src/features”},
glue={“steps”},
tags={“@sanity,@prod”},
plugin = {“pretty”,”html:target/cucumber”, “com.cucumber.listner.ExtentCucumberFormatter”})
public class RunCukes
{
@BeforeClass
public static void setup() {
ExtentCucumberFormatter.initiateExtentCucumberFormatter();
ExtentCucumberFormatter.loadConfig(new File("src/extent-config.xml"));
// User can add the system information as follows
ExtentCucumberFormatter.addSystemInfo("Browser Name", "Firefox");
ExtentCucumberFormatter.addSystemInfo("Browser version", "v49.0.2");
ExtentCucumberFormatter.addSystemInfo("Selenium version", "v3.0.1");
}
}
This issue is resolved
How did you resolve? It would be great if you can share the details here.
In my case, report file is not generated.
Please share runner class.
Thanks
The runner class is shared in the example shown in this article. Kindly share your code for us to help you better.
Hi Doulat,
May I please how did you resolved the issue?
Thanks!
Hi Vimal,
Thank you for the great plugin !!! I have encountered a problem with the plugin when ever Scneario Outline is used with Examples. Report is printing the steps from the last scenario steps. My scenario is given below
Scenario Outline: Login to website
Given User is on Login Page
When User Enters “” in userName Textbox
And User Enters “” in Password Textbox
And User Select “” in Domain Combobox
And User Clicks LoginButton
Then Home Page is displayed
Examples:
| UserName | Password | Domain |
| abc | def | ghk |
Scenario: Click on Collabaration zone
Given User is on Home Page
When User clicks Collabaration zone
Then Collabaration Zone Tab should be opened
The report logs correctly for the first scenario. However for second scenario it is just repeating the steps for first scenario with values.
Could you please help in resolving this.
Regards,
Hi Manjunath,
Yes there is an issue which have been reported already: https://github.com/email2vimalraj/CucumberExtentReporter/issues/2.
I’m working on it and please watch for a new hot fix announcement.
This is now fixed with the new release v1.1.0. Kindly refer here: http://www.vimalselvam.com/cucumber-extent-reporter/
Hi Vimal,
One more observation from my side. If the system on which test is being run is not connected to internet then the reporting format is not displayed.
We work for bank and mostly on intranet. Is there any work around for this.
Regards,
The report that being generated by default will work under no internet condition.
Hi Manjunath,
Kindly ignore my previous reply. Its my mistake. I’ve just released a new version with the support to generate the report offline.
Refer here: http://www.vimalselvam.com/cucumber-extent-reporter/
hi Vimal,
is there a way to modify the path of report generation?
i need this as i have to configure the path of the report to jenkins worksspace so that the jenkins job can send mail with report
thanks and regards,
karthik
Yes there is. It has been mentioned in the article itself. Use this to generate report at your desired location: @CucumberOptions(plugin = {“com.cucumber.listener.ExtentCucumberFormatter:output/report.html”}). This will generate report.html at output directory.
Hi Karthik,
Are you able to setup jenkins to pick up the report and send it through email, if yes can you please let me know how did you do that?
Cheers
Kishore
Where are you stuck?
Hi Vimal,
Its working as expected. Thank you for extending it to cucumber. However i could see total tests count is incorrect when i executed scenarios.
Tests view its showing 6 tests failed which is correct but total tests count is being shown as 12. Could you please let me know if there is any issue with plugin.
You might have to filter to show only Child tests. Try it. If not working, kindly log issue with supported attachments in the github repo: https://github.com/email2vimalraj/CucumberExtentReporter/issues
Its my bad.. Showing only child tests is working as expected. One more question, in the categories sections it is counting feature name also as one test along with other tests that were failed. For now its not a priority for me as dashboard is showing correct results. However, please let me know in case am missing something here.
Hi Vimal,
How we can add screen shots to the report.
Refer here on how to add the screenshot: https://github.com/email2vimalraj/CucumberExtentReporter/blob/master/src/test/java/com/cucumber/stepdefinitions/selenium/Google.java#L39
Hey Vimal,
Thanks for the awesome plugin. I am following your instructions on the readme to load the extent-config.xml in my run class
(ExtentCucumberFormatter.loadConfig(new File(“your config xml file path”));)
but it seems like the loadConfig is not available. Any idea on how to fix it?
Thanks,
Kyle
Actually I just realized that I was using 1.0.0 not 1.1.0. It’s working as expected now. Thanks!
Hi Kyle
Glad it worked for you.
Hi Vimal,
Thanks for this wonderful report ,when I implemented this report using version 1.0.0 everything worked fine however when I used version 1.1.0 I got the below errors. Also, is there a way this report can be shared? so that other team members can see it because at the moment it sits on my local.
java.lang.NullPointerException
at com.cucumber.listener.ExtentCucumberFormatter.close(ExtentCucumberFormatter.java:219)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:290)
at com.sun.proxy.$Proxy19.close(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.close(JUnitReporter.java:213)
at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Kind regards
Akin
Hello Vimal,
Even I’m also facing the same issue. When i looked at the code i thought I might have to pass the systemInfo but even after that its the same issue. Any idea why this is happening?
Regards
Shashi
Shashi, there are few improvements happened in v1.1.0. Kindly go through the readme instructions mentioned here: https://github.com/email2vimalraj/CucumberExtentReporter/blob/master/Readme.md.
Feel free to raise an issue in the github if you face the issue still.
Shasi, refer https://github.com/email2vimalraj/CucumberExtentReporter/issues/16 for more details.
Akin, you might be missing the @BeforeClass as mentioned in the readme. This is the new change incorporated in the v1.1.0. Refer https://github.com/email2vimalraj/CucumberExtentReporter/issues/16 for more details.
Hi Vimal,
Thanks for your excellent work. The problem “java.lang.NullPointerException
at com.cucumber.listener.ExtentCucumberFormatter.close(ExtentCucumberFormatter.java:219)” seems to still persist despite all my consultation. Could you please shed more light on this because I am still struggling with it.
Many thanks,
Lawrence
Lawrence Ajay, kindly open an issue in github with any sample project where I can reproduce your problem. Let me try to help you.
Vimal i am getting java.lang.NoSuchMethodError: com.relevantcodes.extentreports.ExtentReports.addSystemInfo(Ljava/util/Map;)Lcom/relevantcodes/extentreports/ExtentReports;
at com.cucumber.listener.ExtentCucumberFormatter.close(ExtentCucumberFormatter.java:228)
please help
Hi Vimal,
Thanks for the awesome plugin.
I am facing issues in generating screenshots through jenkins, local machine screenshots are getting generated and is stored under output directory along with html report.
Jenkins report is generated properly but without screenshot.
workspace output directory of jenkins does not contain any screenshots.
I have used html publisher plugin in jenkins.
I am using @CucumberOptions(plugin = {“com.cucumber.listener.ExtentCucumberFormatter:output/report.html”}) for report generation and same After method which you have mentioned for generating screenshots (without any changes).
Do you have any idea on this issue? waiting for your inputs.
Regards,
Shwetha
Shwetha, are you facing the problem still. Let me know where are you with this issue now. I’ll try to help you.
Please ignore above reply of mine. Seems you solved the issue.
Even, I’m facing the following issue:
java.lang.NullPointerException
at com.cucumber.listener.ExtentCucumberFormatter.close(ExtentCucumberFormatter.java:219)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:290)
at com.sun.proxy.$Proxy12.close(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.close(JUnitReporter.java:213)
at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Any idea how to resolve this?
Thanks,
Tanmoy
Tanmoy, there are few improvements happened in v1.1.0. Kindly go through the readme instructions mentioned here: https://github.com/email2vimalraj/CucumberExtentReporter/blob/master/Readme.md.
Feel free to raise an issue in the github if you face the issue still.
Tanmoy, refer https://github.com/email2vimalraj/CucumberExtentReporter/issues/16 for more details.
Hi Vimal,
Screenshots attachment worked properly without any issues. Mistake was from my end i had created jenkins job name with space so under workspace there was 2 folders created for reporting. After deleting the space in jenkins job name. Screenshots are working fine without issues.
Plugin works both for linux and windows os.
Regards,
Shwetha Kulkarni
Glad it helped you. Thanks for letting me know Shwetha.
Getting issues with the 1.1 jar file
java.lang.NullPointerException
at com.cucumber.listener.ExtentCucumberFormatter.close(ExtentCucumberFormatter.java:219)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:290)
at com.sun.proxy.$Proxy12.close(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.close(JUnitReporter.java:213)
at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
Any solutions for this?
Ishitha, there are few improvements happened in v1.1.0. Kindly go through the readme instructions mentioned here: https://github.com/email2vimalraj/CucumberExtentReporter/blob/master/Readme.md.
Feel free to raise an issue in the github if you face the issue still.
Ishitha, refer https://github.com/email2vimalraj/CucumberExtentReporter/issues/16 for more details.
Does this reporting work real-time to show the step it is executing or it needs completion of cucumber scenario, before report is generated
No it doesn’t show real time execution.
Hi Vimal,
Thanks for integrating cucumber to the extent reports. It works fine for me and generates the cool report. However, i have noticed that for some scenarios the ‘STEPNAME’ is not coming in the report. The details section is showing the status in the correct order however. But without the STEPNAME we wont know which step passed or failed. I am not able to debug the cause as i see scenarios with and without STEPNAME in the same report.
I am using 1.1.0 version.
Hello Vishnu,
I have the same problem, you can help me?
I am using 1.1.0 version.
Thank you
Duarte Ferreira
Kindly open an issue in github with the report and sample project for me to reproduce, this way I can help you quickly.
Hey,
First of all great thanks for this great post.
I have one questio, I am working in a project where a multiple tests (using cuvucmber) are launched.
I would like that the report.html generated will contains the result of all the test, but when I launch the test, the file is overwritte and only contains the information of the last test executed.
I have tryed to edit the “ExtentCucumberFormatter.initiateExtentCucumberFormatter();” as a “ExtentCucumberFormatter.initiateExtentCucumberFormatter(file-path, false);” but it isnt working.
Could you help me?
Thanks in advance!
I believe you are using the older version of the library. Could you please follow this page: http://www.vimalselvam.com/cucumber-extent-reporter/?
Hi
Is there any way to log the custom messages from Step Definitions into Extent Reports?
Please help me if any one have solution for this.
Thanks
Prathap
yes you can..
public Scenario scenario;
scneario.write(“your message”)
Hi Mukund,
Thank you for your response.
Actually right now we are using Cucumber HTML reports. Even this reports look and feel is very good. I tried writing custom messages using write(String) method it is working fine. But issue is when i use multiple write(String) methods in one Step Definition method in HTML reports those custom messages are displaying in single line. So obviously this is creating mess up in reports and i tried by passing (\n) expression also but still its unable to log that messages in line by line.
Can you please look provide me solution how i can log custom messages in line by line instead of in single line.
Thank you in Advance!!!!
Regards,
Prathap
Hi Prathap,
I have the same kind of scenario in my project, and I initialized my scenario in @Before hooks and used scenario.write(“line1”);
scenario.write(“line2);
this works absolutely fine for me.
Hi Vimal,
Is there any option to make a step result as warning or pass any custom message as warning instead of info?
Hi Vimal,
Any update on this?
No Mukund, you can’t do that. The step result is being handled by cucumber and in the CucumberExtentReporter we just listen to the result object.
Hi Regis,
I tried using write methods as you suggested but those messages are logging in single in reports.
For you how messages are logging in reports are they logging in line by line else logging in single line ?
Hi Regis,
Can please prove snap shot of your code how you have written to log messages line by line when we use multiple writers in single glue method.
Hi Vimal,
Whatever issue Vishnu and Duarte Ferreira is getting even am also getting it.
Please help us to resolve this issue.
Sure I’ll look into it and get back to you all.
Prathap, whatever the issue you are mentioning, I’m unable to receive from my end. Kindly raise an issue in github link provided and add the sample project for me to reproduce.
Hi Vimal,
I’m having issues with the Setup, I’ve copied all your Setup() Method’s Code, and ran the Script but I keep getting this Error message:
java.lang.NoSuchMethodError: com.relevantcodes.extentreports.ExtentReports.(Ljava/lang/String;Ljava/lang/Boolean;Lcom/relevantcodes/extentreports/DisplayOrder;Lcom/relevantcodes/extentreports/NetworkMode;Ljava/util/Locale;)
This error message is coming from this: ExtentCucumberFormatter.initiateExtentCucumberFormatter();
I even added this: ExtentCucumberFormatter.initiateExtentCucumberFormatter(new File (“/Users/mbeaman/Desktop/Reports/CRM/cucumberReport.html”));
and this: ExtentCucumberFormatter.initiateExtentCucumberFormatter(new File (“/Users/mbeaman/Desktop/Reports/CRM/cucumberReport.html”), null, null, null, null);
and this: ExtentCucumberFormatter.initiateExtentCucumberFormatter(new File (“/Users/mbeaman/Desktop/Reports/CRM/cucumberReport.html”), false, “OLDEST_FIRST”, “OFFLINE”, null);
but the same error message appears. Please help 🙂
I solved it now, this Cucumber Extent Report Version is really good, works specially well with Scenario Outline.
🙂
Glad you solved it and happy that you liked it.
mark can you let me know how u solved it as i am facing same issue
HI Mark , Please let me know how you resolve this issue? I am also getting same issue.
HI It is resolved now. I have used below dependencies.
xml-apis
xml-apis
2.0.2
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
Report looks very good and thanks for the cucumber integration with extent reports.
Hi Vimal,
Is there any way I can get test step in the report rather than attaching to every scenario, as our product team needs to verify every screenshots.
By the way awesome work.
Thank you for this plug-in.
However, do you have any tips for the reports generated via jenkins? Thanks in advance!
You can use the Jenkins HTML publisher plugin to publish the generated reports through Jenkins.
Hi Vimal i have the reports
@RunWith(Cucumber.class)
@CucumberOptions(
strict = false,
features = “classpath:features”,
plugin = {“com.cucumber.listener.ExtentCucumberFormatter”
Is there any way i can add more comments or Logs in the Report other than just the Scenarion , Feature and Steps Name .
I want to add some comment to the Test with in the Test and i want it to appear on the Report
You help would be appreciated
Hi Ivan,
Currently there is no support for adding custom log message. I’ll add this in the next release. It would be great if you could log an issue in the github project for tracking purpose.
Hi Vimal,
First of all thanks for the cucumber extent integration….
I am facing an issue with screenshot on scenario failure.My feature file contains multiple scenarios and thus in the teardown() method using @After i haven’t killed the browser driver.The problem is 3 screenshots are taken for the scenario failure.
It would be great if you could point me out my mistake.
Share your @After hook for me to debug
Hi Vimal
In my feature file every scenario corresponds to a separate test case. In the generated report, same count of test and steps is displayed.
i want the count of test as the number of scenarios that are executed and not equal to the number of steps.
And the the graph for steps shows some extra steps under info.
can you please let me know what changes need to be done for this change to be reflected in report.
Hi Vimal,
There is some issue with the extent.css.Because of which test logs and screenshots are not getting displayed in the report,even though they are present.
Could you please check this one ?
Kindly log your issue here: https://github.com/email2vimalraj/CucumberExtentReporter/issues
also, attach the report file to debug along with your code to reproduce the issue.
Hi Vimal,
Can you tell me, how to add more columns along with Test Step, Status,Details in extent report.
I want to add some more columns in reports,is it possible ?
You can’t add columns, but you can add table.
Thanks Vimal,
Could you please provide a reference, how to add table in extent reports?
Currently there is no direct way to add. I’ll include this feature in the upcoming release and update here.
Screenshots are not embedded in the report using the command : Reporter.addScreenCaptureFromPath(“path”).
The path is correct and the image exists at the location. The screenshots are saved in .png format and on debug all the functions for adding screenshot are traversed correctly without any exception.
What can be the possible issue
Mr. Tester, kindly log an issue in the github repo with the code sample for me to reproduce the issue. I’ll have a look and try to help you.
Hi Vimal, In my project we are using java 1.6 and the cucumber extent plug in version 3.0.1 is require java 1.8. Is there a way to make it work in java 1.6 ? so that I can eliminate this java version dependency. – Prakash
Unfortunately ExtentReport is dependent on 1.8, so there is no way that you can use with Java 1.6.
Hi Vimal,
Thanks for the for the plugin it is awesome.
The code in cucumber runner works fine but when I use a custom gradle task the plugin not able to read the extentConfig.xml file. It provides the extent report with default config.
How can I make your plugin use the extentConfig.xml from the custom gradle task, below is the task which is running my tests.
task testLocal(dependsOn: [‘testClasses’]) << {
javaexec {
systemProperties = System.properties
main = “cucumber.api.cli.Main”
classpath = sourceSets.test.runtimeClasspath
jvmArgs = [“-Dfile.encoding=UTF-8”, “-Denv=local”]
args = [‘–tags’, “@web”,
‘–plugin’, ‘junit:build/junit-test-report.xml’,
‘–plugin’, ‘pretty’,
‘–plugin’, ‘html:build/cucumber-html-report’,
‘–plugin’, ‘json:build/cucumber-report.json’,
‘–plugin’, ‘com.cucumber.listener.ExtentCucumberFormatter:masterdash-ui-test/build/extentreport.html’,
‘–glue’, ‘utils’,
‘–glue’, ‘context’,
‘–glue’, ‘stepDefs’,
‘–strict’,
‘src/test/resources’
]
}
}
Hi vimal,
Thanks for providing a wonderful reports. But could you please explain me how can I generate a single report for parallel execution. Please provide me a example.
Thanks
Does cucumber supports parallel execution?
The above question is for cucumber extent report framework