extentreports-java icon indicating copy to clipboard operation
extentreports-java copied to clipboard

In extent report log, how to add test step and exception when an exception is thrown

Open softwaredev999 opened this issue 2 years ago • 0 comments

Hi


// new instance
ExtentReports extent = new ExtentReports(file-path, replaceExisting);

// starting test
ExtentTest test = extent.startTest("Test Name", "Sample description");

// step log
test.log(LogStatus.PASS, "Step details");

try {
	File file = new File("E://file.txt");
        FileReader fr = new FileReader(file);			
	}catch(Exception e) {
	          test.log(LogStatus.FAIL, "unable to find file path", e);			
	}
// ending test
extent.endTest(test);

// writing everything to document
extent.flush();

image

test.log(LogStatus.FAIL, "unable to find file path", e); Currently I only see exception being logged. Why it does not print step details "unable to find file path" as well when exception is thrown?

Thank you!

softwaredev999 avatar Jul 08 '22 22:07 softwaredev999