Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query on build Extent report 4 #128

Closed
Ashwini1980 opened this issue Feb 15, 2020 · 2 comments
Closed

Query on build Extent report 4 #128

Ashwini1980 opened this issue Feb 15, 2020 · 2 comments

Comments

@Ashwini1980
Copy link

Ashwini1980 commented Feb 15, 2020

Hi Anshoo ,

I wan to know if we have any method to show the latest result first in Extent report as earlier we had DisplayOrder.NewestFirst. In 4.x do we have alternative?

I am facing some issues while integrating with Retry analyzer with Extent Report.

Retry Analyzer:

@Override
public boolean retry(ITestResult iTestResult) {
	if (!iTestResult.isSuccess()) {
		if (count < maxTry) { 
			count++; 
			iTestResult.setStatus(ITestResult.FAILURE); 				
			return true; // Tells TestNG to re-run the test
		}
	} else {
		iTestResult.setStatus(ITestResult.SUCCESS); // If test passes, TestNG marks it as passed
	}
	return false;
}

In the Listener I have configured as follows:

public synchronized void onFinish(ITestContext context) {
	
	Iterator<ITestResult> failedTestCases =context.getFailedTests().getAllResults().iterator();
    Set<ITestResult> skippedTests = context.getSkippedTests().getAllResults();
    
    while (failedTestCases.hasNext()) {
        System.out.println("failedTestCases");
        ITestResult failedTestCase = failedTestCases.next();
        ITestNGMethod method = failedTestCase.getMethod();
        if (context.getFailedTests().getResults(method).size() > 1) {
            System.out.println("failed test case remove as dup:" + failedTestCase.getTestClass().toString());
            failedTestCases.remove();
            ExtentService.getInstance().removeTest(ExtentTestManager.getTest());
        } else {

            if (context.getPassedTests().getResults(method).size() > 0) {
                System.out.println("failed test case remove as pass retry:" + failedTestCase.getTestClass().toString());
                failedTestCases.remove();
                ExtentService.getInstance().removeTest(ExtentTestManager.getTest());
            }
        }
    }
    
    for (ITestResult temp : skippedTests) {
   	
    	skippedTests.remove(temp);
    	ExtentService.getInstance().removeTest(ExtentTestManager.getTest(temp));
    }
    ExtentService.getInstance().flush();
}

Scenario:

In a given suite I have 3 test cases and I have set max retry =2

  1. test case 1 passed
  2. test case 2 failed (Retried 2 times)
  3. test case 3 failed (Retried 2 times)

In the testng report I am getting the expected result i.e. 1 passed and 2 failed and total 3 test cases but in the Extent Report it is showing 1 passed, 2 skipped and 2 failed. If we calculate total test cases it's showing 5 in the extent report. I want to delete all the skipped test cases from the report. How to do that?

Can you please help?
@anshooarora

@Ashwini1980
Copy link
Author

This issue is resolved and hence closing this.

@suhasg2020
Copy link

Hi @Ashwini1980 can you please share a solution for the same issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants