damianszczepanik / cucumber-reporting

HTML reports for Cucumber
GNU Lesser General Public License v2.1
542 stars 403 forks source link

How to customize json report generated by cucumber to feed it to this cucumber-reporting tool #1178

Closed dongkyu9315 closed 3 months ago

dongkyu9315 commented 3 months ago

Hi,

I was able to use a pluging wrapper [1] of this package to generate a report. I would like to add some more details on each scenario and steps. For example, if you see line 156 of the sample.json file [2], it has description field, which is shown in the generated report with yellow background in the screenshots in this page [3]. Also, there's comments field [4] for each step, which is also shown in the generated report. The current generated json file using --plugin json:output/report.json command has a description field as empty string. How do I update this description field or add comments field at runtime (hopefully inside the cucumber step definition methods) so that these values are shown in the generated report? I've been trying to find ways to modify this json report, but it seems like there's not much info online.

Looking forward to hearing from you guys! Thanks

[1] https://gitlab.com/jamietanna/cucumber-reporting-plugin [2] https://github.com/damianszczepanik/cucumber-reporting/blob/019385d352a6676808c70830f2b31481af776750/src/test/resources/json/sample.json#L156 [3] https://github.com/damianszczepanik/cucumber-reporting [4] https://github.com/damianszczepanik/cucumber-reporting/blob/019385d352a6676808c70830f2b31481af776750/src/test/resources/json/sample.json#L396

damianszczepanik commented 3 months ago

Description is supported eg https://damianszczepanik.github.io/cucumber-html-reports/report-feature_1920820787.html but comment is AFAIK not formally specified so there is no support for that

dongkyu9315 commented 3 months ago

Thank you so much for your reply.

So you are saying the comment is not supported for now, but the html link that you sent has these comments [1] for the test steps. Is this html something that the cucumber-reporting tool generated based on a JSON report that's auto-generated by a formatter? Or is it an html file that you manually edited afterwards?

I just need a way to add some custom data (which is generated at runtime of test step) to each test step, but it does not seem to simple... Maybe I need to create a custom formatter to generate a JSON report in a format that this cucumber-reporting tool can accept. If you have any other opinions or suggestions, please let me know. Thanks!

[1]

# Some comments
# Some more comments
damianszczepanik commented 3 months ago

Right, comments is supported https://github.com/damianszczepanik/cucumber-reporting/blob/master/src/test/resources/json/sample.json#L65-L74 but custom data can be added via classifications only https://github.com/damianszczepanik/cucumber-reporting/blob/master/src/test/java/LiveDemoTest.java#L33-L34