How to write a custom Failure message for the Failed Step in Cucumber-java in extentReports How to write a custom Failure message for the Failed Step in Cucumber-java in extentReports selenium selenium

How to write a custom Failure message for the Failed Step in Cucumber-java in extentReports


Have you tried using the create label markup?

Here is how to do it for the FAILED test:

test.log(Status.FAIL, MarkupHelper.createLabel(result.getName()+" Your MSG here!", ExtentColor.RED)); 

and the PASSED test:

test.log(Status.PASS, MarkupHelper.createLabel(result.getName()+" Test Case PASSED", ExtentColor.GREEN));

You can easily manipulate the string part (var interpolation?) according to your need.

Does this help?


try to replace the JUnit assertion library with the testNG library...also using cucumber you can see the failed step...why do you want to change this "narrative" log?...or if you want a better report try to use a 3rd party library