Ask a Question

How to modify the scenario.write default text

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:


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




Which cucumber are you using? cucumber-jvm?


Which version?


Which formatter are you specifying?



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



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:



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?



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/
  • 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
Showing results for 
Search instead for 
Did you mean: