Open ghost opened 6 years ago
@anshooarora - could you please help out here.
This should work:
public class ExtentTestNGReportBuilder {
private static ExtentReports extent = ExtentManager.createInstance("test-output/extent.html");
private static ThreadLocal<ExtentTest> parentTest = new ThreadLocal();
private static ThreadLocal<ExtentTest> test = new ThreadLocal();
@BeforeClass
public synchronized void beforeClass() {
ExtentTest parent = extent.createTest(getClass().getName());
parentTest.set(parent);
}
@BeforeMethod
public synchronized void beforeMethod(Method method) {
ExtentTest child = parentTest.get().createNode(method.getName());
test.set(child);
}
@AfterMethod
public synchronized void afterMethod(ITestResult result) {
if (result.getStatus() == ITestResult.FAILURE)
test.get().fail(result.getThrowable());
else if (result.getStatus() == ITestResult.SKIP)
test.get().skip(result.getThrowable());
else
test.get().pass("Test passed");
extent.flush();
}
}
public class ExtentManager {
private static ExtentReports extent;
public static ExtentReports getInstance() {
if (extent == null)
createInstance("test-output/extent.html");
return extent;
}
public static ExtentReports createInstance(String fileName) {
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(fileName);
htmlReporter.config().setTestViewChartLocation(ChartLocation.BOTTOM);
htmlReporter.config().setChartVisibilityOnOpen(true);
htmlReporter.config().setTheme(Theme.STANDARD);
htmlReporter.config().setDocumentTitle(fileName);
htmlReporter.config().setEncoding("utf-8");
htmlReporter.config().setReportName(fileName);
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
return extent;
}
}
Summary
Not able to generate a single extent report for different class files with 3.1.5 version
Expected Behavior
Test results from different classes should get updated in Extent report
Current Behavior
Test results from different classes are not getting updated in Extent report. It is showing test results for TCs in one class file not in other files.
Sample
Environment Details
Screenshots