cancel
Showing results for 
Search instead for 
Did you mean: 

How to modify the scenario.write default text

hocutz
New Contributor

How to modify the scenario.write default text

When I use scenario.write I get the text under an Output 1 label in the html report.

Like this: https://user-images.githubusercontent.com/17196589/116504696-8bfccb80-a8d6-11eb-856a-0d459d0d8df1.pn...

 

Is there any way to modify the label's name?

 

Thanks

5 REPLIES 5

Re: How to modify the scenario.write default text

Which cucumber are you using? cucumber-jvm?

 

Which version?

 

Which formatter are you specifying?

hocutz
New Contributor

Re: How to modify the scenario.write default text

Hi,

 

I'm using info.cuckes 1.2.4 with Java Spring, Masterthought reporter and json as formatter.

 

Thanks

Re: How to modify the scenario.write default text

Thanks for the info.

So actually this is not related to cucumber, but certainly to Masterthought cucumber reporter.

You are using the json formatter from cucumber. Your output is not identified as "Output 1" by cucumber or its json formater. Masterthought cucumber-reporting do that, and I do not know that tool myself.

 

You'll certainly be able to get more appropriate help from the developer: https://github.com/damianszczepanik/cucumber-reporting

hocutz
New Contributor

Re: How to modify the scenario.write default text

Hi,

 

Thanks for the reply.

 

Masterthought only interprets the info that is found in the json afaik.

I just opened up the json file, the one created by cucumber, and there is a field in it called: "output" which was created by the scenario.write function (basically the output is something like this: output: "text written in the function")

And to expand a bit, scenario.write function seems to be linked to the ScenarioImpl.class from cucumber.runtime package, and from there it goes into the Reporter class from the Gherkin Formatter classes.

 

Any thoughts?

 

Thanks

Re: How to modify the scenario.write default text

Yes, the json contains that "output" key. This is how data are structured within the json formatter: this is the name of a field, an internal identifier. It is up to the final renderer if built upon the json report to decide how to render that info.

 

Masterthought decided to render the name of that field capitalizing it and adding an index to it.

 

The cucumber built-in html formatter does not render the name of that field at all, just its content.

 

I could imagine several ways for you to override "Output N" in your HTML report:

  • writing your own custom formatter which may override the cucumber-jvm json formatter to modify the behavior of "addOutputToHookMap" (cf. cucumber-jvm/JsonFormatter.java:331)
  • add a step before rendering the HTML report to update the json file to replace "output" with what you want
  • see with Masterthought what could be done on their side
New Here?
Join us and watch the welcome video: