Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Test And Test Steps counts are same in the Extent report 3.0.1 #756

Description

@naveenru

I have used extent 3.0.1 version

Issue :Test and Test steps count are same always . Test and test Step count are 2 always . Please help .
Expected result : Test = 1 , Test steps = 2

Test Suite : TS1

Test Cases : tc1 ,tc2

Implementation :

public class ExtentTestNGReportBuilder {

private static ExtentReports extent;
private static ThreadLocal parentTest = new ThreadLocal();
private static ThreadLocal test = new ThreadLocal();

@BeforeSuite
public void beforeSuite() {
	extent = ExtentManager.createInstance("extent.html");
	ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("extent.html");
	extent.attachReporter(htmlReporter);
}

@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;
}

}
image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions