grasshopper7 / extentreports-cucumber6-adapter

Cucumber-JVM 6 Adapter for Extent Framework
https://ghchirp.online/2098/
MIT License
16 stars 15 forks source link

PDF report generated unable to open. #41

Open p00rni opened 3 years ago

p00rni commented 3 years ago

Hi I am working on a web proj.. wih extend report the html report is all gud but pdf gets generated in the location as mentioned in properties file but doesnt open. and the below error msgs are displayed when run as testNG suite.

should i add any dependency or yaml file? - note i do have these dependencies in my pom (

tech.grasshopper extentreports-cucumber6-adapter 2.8.3 com.aventstack extentreports 5.0.8 tech.grasshopper extent-pdf-report 1.7.3 ) ERROR : Aug 09, 2021 4:19:53 PM tech.grasshopper.pdf.extent.ExtentPDFCucumberReporter flush SEVERE: An exception occurred tech.grasshopper.pdf.exception.PdfReportException: java.io.IOException: The TrueType font null does not contain a 'cmap' table at tech.grasshopper.pdf.PDFCucumberReport.createReport(PDFCucumberReport.java:120) at tech.grasshopper.pdf.extent.ExtentPDFCucumberReporter.flush(ExtentPDFCucumberReporter.java:81) at tech.grasshopper.pdf.extent.ExtentPDFCucumberReporter.access$100(ExtentPDFCucumberReporter.java:19) at tech.grasshopper.pdf.extent.ExtentPDFCucumberReporter$1.onNext(ExtentPDFCucumberReporter.java:56) at tech.grasshopper.pdf.extent.ExtentPDFCucumberReporter$1.onNext(ExtentPDFCucumberReporter.java:49) at io.reactivex.rxjava3.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:310) at io.reactivex.rxjava3.subjects.PublishSubject.onNext(PublishSubject.java:226) at com.aventstack.extentreports.ReactiveSubject.onFlush(ReactiveSubject.java:83) at com.aventstack.extentreports.AbstractProcessor.onFlush(AbstractProcessor.java:85) at com.aventstack.extentreports.ExtentReports.flush(ExtentReports.java:284) at com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter.finishReport(ExtentCucumberAdapter.java:300) at com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter.access$600(ExtentCucumberAdapter.java:62) at com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter$8.receive(ExtentCucumberAdapter.java:136) at com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter$8.receive(ExtentCucumberAdapter.java:133) at io.cucumber.core.eventbus.AbstractEventPublisher.send(AbstractEventPublisher.java:51) at io.cucumber.core.eventbus.AbstractEventBus.send(AbstractEventBus.java:12) at io.cucumber.core.runtime.CucumberExecutionContext.emitTestRunFinished(CucumberExecutionContext.java:93) at io.cucumber.core.runtime.CucumberExecutionContext.finishTestRun(CucumberExecutionContext.java:74) at io.cucumber.testng.TestNGCucumberRunner.finish(TestNGCucumberRunner.java:127) at com.snoop.runner.WebAppRunner.tearDownClass(WebAppRunner.java:56) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132) at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61) at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:366) at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:320) at org.testng.internal.TestMethodWorker.invokeAfterClassMethods(TestMethodWorker.java:217) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:130) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.testng.TestRunner.privateRun(TestRunner.java:764) at org.testng.TestRunner.run(TestRunner.java:585) at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) at org.testng.SuiteRunner.run(SuiteRunner.java:286) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218) at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) at org.testng.TestNG.runSuites(TestNG.java:1069) at org.testng.TestNG.run(TestNG.java:1037) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.io.IOException: The TrueType font null does not contain a 'cmap' table at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapImpl(TrueTypeFont.java:561) at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapLookup(TrueTypeFont.java:541) at org.apache.fontbox.ttf.TrueTypeFont.getUnicodeCmapLookup(TrueTypeFont.java:527) at org.apache.fontbox.ttf.TTFSubsetter.(TTFSubsetter.java:90) at org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder.subset(TrueTypeEmbedder.java:346) at org.apache.pdfbox.pdmodel.font.PDType0Font.subset(PDType0Font.java:256) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1349) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1328) at tech.grasshopper.pdf.PDFCucumberReport.createReport(PDFCucumberReport.java:116) ... 45 more
p00rni commented 3 years ago

I DO HAVE THE FOLLOWING DEPENDANCIES IN POM AND HAVE THE EXTENT-CONFIG.XML AND PROPERTIES FILE

tech.grasshopper extentreports-cucumber6-adapter 2.8.3 com.aventstack extentreports 5.0.8 tech.grasshopper extent-pdf-report 1.7.3
grasshopper7 commented 3 years ago

What is the dialect or language? The PDF uses an open source font family - Liberation for display and some languages are not supported. U can refer to this this comment for more details - https://ghchirp.tech/2224/#comment-2035

Have u tried the reference project to create the pdf report? https://github.com/grasshopper7/cuke6-extent-adapter-report

U just need to add the extentreports-cucumber6-adapter dependency in POM. Rest are transitive dependencies ( extentreports and extent-pdf-report).

p00rni commented 3 years ago

Hi, Thank you for a quick response. having got the right dependancies i see pdf report generates fine now.

I am running 3 tests simultaniously (in 3 diff browser platforms) - the html report gives a consolidated view of all the 3 tests. this is where the pdf generating crashes.

when we run only one test - (in only one browser) - pdf generation works

but not when multiple tests are run . any directions to this would be helpful. (is ther anyway to do tis without having to change my framework towards parallel execution approach? )

grasshopper7 commented 3 years ago

If there are multiple runners then do not use the adapter plugin method for creating PDF report. Multiple threads cannot access a single PDF file for writing. This is also mentioned in the article - https://ghchirp.tech/2098/, search for 'PDF Extent Report' section for more details.

Two other ways of creating the PDF report.

First method - Generate the PDF report by using a Maven plugin which will execute in the 'post-integration-test' phase. This uses the cucumber JSON report. The other extent report like Spark can be generated by the existing adpater plugin. Refer to https://ghchirp.tech/2224/, section 'Cucumber Maven Report Plugin'.

Second method - Generate all reports by using a Maven plugin which will execute in the 'post-integration-test' phase. This also uses the cucumber JSON report. No need for adding the adapter plugin to the runners. Refer to https://ghchirp.tech/2114/.

p00rni commented 3 years ago

thank you

i have the following tests in my testng.xml and only 1 runner class to call this xml file. but as it runs 3 tests pdf overriding issue is happening . so trying to create json and using in pm.xml would help .. is that right ?

grasshopper7 commented 3 years ago

If there is only one runner instance, then the PDF report should be generated correctly. Is the setup in the testng.xml creating multiple instances of the runner class?

Can u share the settings? I have never used testng.xml to trigger cucumber runners so will have to understand what you are attempting. Using Maven lifecycle is much simpler.

p00rni commented 3 years ago

this is my testNG file. im running same runner class in 3 diff browsers via testNG

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >

p00rni commented 3 years ago

xml version.docx

p00rni commented 3 years ago

i have extent.config and extent.properties as per guidance. and here is my runnerclass method

@RunWith(Cucumber.class) @CucumberOptions( features = "src/test/resources/features",

    glue = {"com.stepDefs" }, 
    monochrome = true, 
    tags =  "@linkedState", 
    publish = true,
            plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:",
                    "json:target/json-report/cucumber.json"})
p00rni commented 3 years ago

xml version.docx pom plugin

grasshopper7 commented 3 years ago

You are basically triggering three instances of the runner class. The PDF report will not work correctly. U will need to use the alternate techniques I had mentioned in the previous comment. The testng.xml will have to be added to the surefire or failsafe plugin settings.

p00rni commented 3 years ago

hi , I have dropped including pdf as the html report looks good . and for html report - i only addded the plugin adapter "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:" to the runner class .. and jave config file and properties file added to resourches. the dependancies in the pom.xml .

could you help with if thre is a any repo reference to add screenshots with the reports please ? without creating too many additional classes? thanks

snpanigrahi9 commented 1 year ago

@grasshopper7 Any update on this issue. I facing the same issue for my framework. I have multiple @test in my testng.xml file and each test is executing the same TestRunner class to achieve parallel testing. In this case, pdf report is generating with 0KB size and not opening. Earlier mentioned link for alternate solutiuon is not opening as well.

grasshopper7 commented 1 year ago

Hi, The links are updated below.

First method - Generate the PDF report by using a Maven plugin (https://github.com/grasshopper7/cucumber-pdf-plugin) which will execute in the 'post-integration-test' phase. This uses the cucumber JSON report. The other extent report like Spark can be generated by the existing adapter plugin. Refer to https://ghchirp.site/2224/, section 'Maven plugin configuration'.

Second method - Generate all reports by using a Maven plugin which will execute in the 'post-integration-test' phase. This also uses the cucumber JSON report. No need for adding the adapter plugin to the runners. Refer to https://ghchirp.site/2114/.

You will need to pass different values for the cucumber json report in testng.xml. Refer to these links - https://stackoverflow.com/questions/74703840/can-we-pass-cucumber-options-values-like-features-and-tags-values-dynamically-fr https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-core#cucumber-core