How to write a custom error message for a failed step in Cucumber-java in the format

I want to write a custom error message in my OucentReports instance.

Tool use:

Cucumbers

Java

Selenium

Junit

Extentreports

What is happening now:

I have a cucumber script.

Given something When I do something Then this step fails 

Failed to fail:

 Assert.assertTrue("CUSTOM_FAIL_MSG", some_condition); 

In ExtentReport I see enter image description here

What I want to achieve:

enter image description here

What I have investigated so far:

There is a scenario.write("") function, but this creates a new informational log in the report (But I'm looking for a CustomFailure message, not a new log entry)

scenario.stepResults has a row that appears in the report. However, I could not find a way to set some value in the same.

Any ideas on this?

+8
junit4 selenium cucumber-java selenium-extent-report
source share
1 answer

Have you tried to use markup markup markup?

Here's 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 part of the string (var interpolation?) According to your needs.

Does it help?

0
source share

All Articles