Skip to content
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

Closed
naveenru opened this issue Jan 31, 2017 · 53 comments
Closed

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

naveenru opened this issue Jan 31, 2017 · 53 comments

Comments

@naveenru
Copy link

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

@anshooarora
Copy link
Owner

I see 2 tests. How many logs does each toggle have?

@naveenru
Copy link
Author

naveenru commented Feb 1, 2017

image

Actually I am running 3 classes

Class 1 - has 6 tests
Class 2 - has 24 tests
Class 3 - has 5 Tests

Result after running : Tests run: 35, Failures: 6, Errors: 0, Skipped: 23

Questions :

  1. I need to know why it shows test ans test steps count same .
  2. Is there a way where i can disable the Test steps view in dashboard .

@RodNepoLNRisk
Copy link

Hi,

I'm Rod. I agree to the post, the counts for the Passed or Failed Tests are the same with the Steps.
tests count is always the same with steps count

@anshooarora
Copy link
Owner

Can you check if the issue persists with version 3.0.3?

Also, if it does, can you share a small sample that I can use to repro? Thanks.

@RodNepoLNRisk
Copy link

Yes. I'm using 3.0.3 version.

com.aventstack
extentreports
3.0.3

I have a GenerateExtentReport class then createTest for parentTest then assign the Test Suite as Category
GenerateExtentReports3.parentTest = GenerateExtentReports3.extent.createTest(strTestCaseNumName, strTestDesc);
GenerateExtentReports3.parentTest.assignCategory(strTestSuite);

then I call the method for the Test Steps:
//Step #1
public void verifyADRNavPaneLocation () {
//====================================================================================================================
//1) Verify the Navigation Pane for the Account Detail Report is displayed to the left of the report and allows the user to any section of the report.
strStepDesc = " Verify the Navigation Pane for the Account Detail Report is displayed to the left of the report and allows the user to any section of the report.";
strScreenshot = strTestCaseNumName + " - " + strStepNo;
strStepName = strStepNo + " - " + strStepDesc;

	if (AccountDetailReportNavigationPaneBus.isNavPaneOnUpperLeft() &&
		AccountDetailReportNavigationPaneBus.verifyNavigateContributionDates()) {
		//PASSED
		strDetails = strStepNo + "-" + Common.PASSED + " - Verified that the Navigation Pane for the Account Detail Report is displayed to the left of the report and allows the user to any section of the report.";
		System.out.println (strDetails);			
		strTestRemarks = strTestRemarks + strDetails + "\n";
		
		//GenerateExtentReports2.testPass(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		
		if (MainRunTest.strExtReportProperties.equals(MainRunTest.strExtReportCommon)) {
			GenerateExtentReports2.testPass(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		} else {
			try {
				GenerateExtentReports3.getResult(TestVars.resSUCCESS, driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, 
						strTestDesc, strDetails);
			} catch (IOException e) {
				e.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	} else {
		//FAILED
		if (AccountDetailReportNavigationPaneBus.getErrorDescription().length() > 0) {
			strDetails = strStepNo + "-" + Common.FAILED + " - Verified that the Navigation Pane for the Account Detail Report is NOT displayed to the left of the report and DOES NOT allow the user to any section of the report." +
					AccountDetailReportNavigationPaneBus.getErrorDescription();
		}
		blnTestPassed = false;
		System.out.println (strDetails);			
		strTestRemarks = strTestRemarks + strDetails + "\n";
		
		//GenerateExtentReports2.testFail(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		
		if (MainRunTest.strExtReportProperties.equals(MainRunTest.strExtReportCommon)) {
			GenerateExtentReports2.testFail(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		} else {
			try {
				GenerateExtentReports3.getResult(TestVars.resFAILURE, driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, 
						strTestDesc, strDetails);
			} catch (IOException e) {
				e.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}	
	}		
}

//Step #2
public void verifyADRNavPaneSectionDetails () {		
	//====================================================================================================================		
	//2) Verify the Navigation Pane headings and navigation areas will include the following along with their counts if applicable:
	//	•  Account Contribution Heading
	//	   This will allow the user to go back to the most recent reported contribution date 
	//	   (i.e. top of report);
	//		•  Account Credit Information  
	//		•  Account Activity 
	//		•  Payment Information  
	//		•  Past Due Information  
	//		•  Charge-off Information  
	//		•  Account Tax IDs/SSNs <insert count of TI segments related to the AB segment>
	//		•  Account Addresses <insert count of AD segments related to the AB segment>
	//		•  Account Phones <insert count of PN segments related to the AB segment>
	//		•  Account Business Classification Information <insert count of BI segments related to the AB segment>
	//		•  Collateral Information <insert count of CL segment data within this section related to the AB segment>
	//		•  UCC Information <insert count of CL segment data within this section related to the AB segment>
	//		•  Account Modification History <insert count of AH segments related to the AB segment>
	//		•  Account Member Specific Reported Fields <insert count of AD segments related to the AB segment>
	//		•  Guarantor/Owner Summary
	//	            o  Individuals Related to the Business Entity <insert count of IS segments related to the AB segment>
	//	            o  Other Businesses Related to the Business Entity <insert count of BS segments related to the AB segment>
	//	•  History of All Account Contributions <insert count of account contributions reported>
	//	    •  Account Contribution Heading
	//	   This will allow the user to go back to the contribution date field for the account detail; no count provided
	strStepDesc = "the Navigation Pane headings and navigation areas will include the following along with their counts if applicable \n" +
				  "	•  Account Contribution Heading \n" +
				  "	  This will allow the user to go back to the most recent reported contribution date (i.e. top of report); \n" +
				  "	  	•  Account Credit Information \n" +  
				  "		•  Account Activity \n" +
				  "		•  Payment Information \n" +  
				  "		•  Past Due Information \n" +  
				  "		•  Charge-off Information \n" +  
				  "		•  Account Tax IDs/SSNs <insert count of TI segments related to the AB segment> \n" +
				  "		•  Account Addresses <insert count of AD segments related to the AB segment> \n" +
				  "		•  Account Phones <insert count of PN segments related to the AB segment> \n" +
				  "		•  Account Business Classification Information <insert count of BI segments related to the AB segment> \n" +
				  "		•  Collateral Information <insert count of CL segment data within this section related to the AB segment> \n" +
				  "		•  UCC Information <insert count of CL segment data within this section related to the AB segment> \n" +
				  "		•  Account Modification History <insert count of AH segments related to the AB segment> \n" +
				  "		•  Account Member Specific Reported Fields <insert count of AD segments related to the AB segment> \n" +
				  "		•  Guarantor/Owner Summary \n" +
				  "        o  Individuals Related to the Business Entity <insert count of IS segments related to the AB segment> \n" +
				  "        o  Other Businesses Related to the Business Entity <insert count of BS segments related to the AB segment> \n" +
				  "	•  History of All Account Contributions <insert count of account contributions reported> \n" +
				  "	   •  Account Contribution Heading \n" +
				  "	   This will allow the user to go back to the contribution date field for the account detail; no count provided \n";
	strScreenshot =  strTestCaseNumName + " - " + strStepNo;
	strStepName = strStepNo + " - Verify " + strStepDesc;

	if (!AccountDetailReportNavigationPaneBus.verifyNavigationPaneSections() ) {
		//PASSED
		strDetails = strStepNo + "-" + Common.PASSED + " - Verified that the " + strStepDesc;
		System.out.println (strDetails);			
		strTestRemarks = strTestRemarks + strDetails + "\n";
		
		//GenerateExtentReports2.testPass(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		
		if (MainRunTest.strExtReportProperties.equals(MainRunTest.strExtReportCommon)) {
			GenerateExtentReports2.testPass(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		} else {
			try {
				GenerateExtentReports3.getResult(TestVars.resSUCCESS, driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, 
						strTestDesc, strDetails);
			} catch (IOException e) {
				e.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}			
	} else {
		//FAILED
		if (AccountDetailReportNavigationPaneBus.getErrorDescription().length() > 0) {
			strDetails = strStepNo + "-" + Common.FAILED + " - Verified that the Navigation Pane headings encountered some errors. \n" +
					AccountDetailReportNavigationPaneBus.getErrorDescription();
		}
		blnTestPassed = false;
		System.out.println (strDetails);			
		strTestRemarks = strTestRemarks + strDetails + "\n";
		
		//GenerateExtentReports2.testFail(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		
		if (MainRunTest.strExtReportProperties.equals(MainRunTest.strExtReportCommon)) {
			GenerateExtentReports2.testFail(driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, strTestDesc, strDetails);
		} else {
			try {
				GenerateExtentReports3.getResult(TestVars.resFAILURE, driver, strTestSuite, strTestCaseNumName, strStepName, strScreenshot, 
						strTestDesc, strDetails);
			} catch (IOException e) {
				e.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}	
	}		
}

I have a method getResults where I pass if the Test Step is a Pass or Fail.
public static void getResult(String result, WebDriver pdriver, String pstrTestSuite, String pstrTestCaseNumName
, String pstrStepName, String pstrScreenshot, String pstrTestDesc, String pstrDetails) throws IOException, Exception {

	switch (result) {
        case TestVars.resSUCCESS:
        	childTest = parentTest.createNode(pstrStepName);
        	childTest.log(Status.PASS, MarkupHelper.createLabel(pstrStepName, ExtentColor.GREEN));
        	childTest.addScreenCaptureFromPath(captureScreenShot(pdriver, pstrScreenshot));
        	childTest.log(Status.INFO, MarkupHelper.createLabel(pstrDetails, ExtentColor.GREY));
    		Assert.assertTrue(true);
    		break;
        case TestVars.resFAILURE:
        	childTest = parentTest.createNode(pstrStepName);
        	childTest.log(Status.FAIL, MarkupHelper.createLabel(pstrStepName, ExtentColor.RED));
        	childTest.addScreenCaptureFromPath(captureScreenShot(pdriver, pstrScreenshot));
        	childTest.log(Status.INFO, MarkupHelper.createLabel(pstrDetails, ExtentColor.GREY));	        		        	
    		Assert.assertFalse(false);
    		break;
        case TestVars.resSKIP:
        	strMsg = pstrTestCaseNumName + " - " + Common.SKIPPED;
        	parentTest = extent.createTest(pstrTestCaseNumName, pstrTestDesc);
        	parentTest.assignCategory(pstrTestSuite);
        	parentTest.log(Status.SKIP, MarkupHelper.createLabel(strMsg, ExtentColor.ORANGE));
    		Assert.assertTrue(true);
    		break;
        default:
        	strMsg = pstrTestCaseNumName + " - " + Common.SKIPPED;
        	parentTest = extent.createTest(pstrTestCaseNumName, pstrTestDesc);
        	parentTest.assignCategory(pstrTestSuite);
        	parentTest.log(Status.SKIP, MarkupHelper.createLabel(strMsg, ExtentColor.ORANGE));
    		Assert.assertTrue(true);
    		break;
    }        
}

@anshooarora
Copy link
Owner

Please attach a project. Its going to be difficult and time-consuming for me to fill in all the missing details and recreate the project from scratch.

With that being said, the 2 counts you have shown may not necessarily match. That is because:

  1. You may have marked the parent-test with the category but it has several child tests. The child tests will show up in the final counts.
  2. You may not have assigned all tests to categories which can also result in different counts from category and overall test count.

@RodNepoLNRisk
Copy link

Hi,
The project is too big. Do you have a sample code where it shows how to use ParentTest and ChildTest nodes? ParentTest being the Tests and ChildTest being the steps and how the Categories are assigned. I followed it as how I understood it but maybe there's a missed step. Thanks.

@RodNepoLNRisk
Copy link

I really think that there's something wrong with the counts, please create a small project and create steps and tests and see if the counts are the same. maybe the Dashboard test count points to the Step counts as well. Thanks for the help.

@RodNepoLNRisk
Copy link

I also noticed that in Extent Reports v.2.41.2 the Category Summary totals are not displayed, but the Test and Step counts are correct.

category summary totals not displayed for extent report v2 41 2

@anshooarora
Copy link
Owner

@RodNepoLNRisk if you assign the category to the child tests are well, this issue will go away. The report will not automatically mark the childNodes with the same category as the parent test which is why you are seeing this issue. As I had mentioned in the 1st bullet above:

You may have marked the parent-test with the category but it has several child tests. The child tests will show up in the final counts.

For the above, version 2 has several differences in comparison to 3 which is why you see this behavior..

@RodNepoLNRisk
Copy link

I'll try your suggestion for version 3, but for version 2, how can I see the Summary Totals for the Category section?

@RodNepoLNRisk
Copy link

I did what you asked and assigned the Category to the child tests and the totals are no longer correct and the Categories view displayed the Steps together with the Tests instead of having it as a drilldown.
Please take a look at the Tests Count from the Dashboard, regardless if I set the Categories to the Child Test it still displayed an incorrect value, it seems like it points to the Steps Total. I really appreciate the help on this. Thanks.

extent report v3 category discrepancies image2
extent report v3 summary discrepancies image1

@RodNepoLNRisk
Copy link

This is the method that I call for Pass, Fail, Skip.
I now commented out the part where I assigned the Category to the Child Test.
I'll try to generate it again and see the difference.

public static void getResult(String result, WebDriver pdriver, String pstrTestSuite, String pstrTestCaseNumName
		, String pstrStepName,  String pstrScreenshot, String pstrTestDesc, String pstrDetails) throws IOException, Exception {
	
	switch (result) {
        case TestVars.resSUCCESS:
        	childTest = parentTest.createNode(pstrStepName);
        	//childTest.assignCategory(pstrTestSuite);
        	childTest.log(Status.PASS, MarkupHelper.createLabel(pstrStepName, ExtentColor.GREEN));
        	childTest.addScreenCaptureFromPath(captureScreenShot(pdriver, pstrScreenshot));
        	childTest.log(Status.INFO, MarkupHelper.createLabel(pstrDetails, ExtentColor.GREY));
    		Assert.assertTrue(true);
    		break;
        case TestVars.resFAILURE:
        	childTest = parentTest.createNode(pstrStepName);
        	//childTest.assignCategory(pstrTestSuite);
        	childTest.log(Status.FAIL, MarkupHelper.createLabel(pstrStepName, ExtentColor.RED));
        	childTest.addScreenCaptureFromPath(captureScreenShot(pdriver, pstrScreenshot));
        	childTest.log(Status.INFO, MarkupHelper.createLabel(pstrDetails, ExtentColor.GREY));	        		        	
    		Assert.assertFalse(false);
    		break;
        case TestVars.resSKIP:
        	if (pstrStepName.length() > 0) {
        		//The Test Step Number for the Test Case have been skipped
	        	strMsg = pstrTestCaseNumName + " - " + pstrStepName + Common.SKIPPED;
	        	childTest = parentTest.createNode(pstrStepName);
	        	childTest.assignCategory(pstrTestSuite);
	        	childTest.log(Status.SKIP, MarkupHelper.createLabel(pstrStepName, ExtentColor.ORANGE));
	        	childTest.log(Status.INFO, MarkupHelper.createLabel(strMsg, ExtentColor.GREY));		        	
	    		Assert.assertTrue(true);
        	} else {
        		//The Test Case Number with Test Case Name have been skipped
	        	strMsg = pstrTestCaseNumName + " - " + Common.SKIPPED;
	        	parentTest = extent.createTest(pstrTestCaseNumName, pstrTestDesc);
	        	parentTest.assignCategory(pstrTestSuite);
	        	parentTest.log(Status.SKIP, MarkupHelper.createLabel(strMsg, ExtentColor.ORANGE));
	    		Assert.assertTrue(true);
        	}
    		break;
        default:
        	if (pstrStepName.length() > 0) {
        		//The Test Step Number for the Test Case have been skipped
	        	strMsg = pstrTestCaseNumName + " - " + pstrStepName + Common.SKIPPED;
	        	childTest = parentTest.createNode(pstrStepName);
	        	childTest.assignCategory(pstrTestSuite);
	        	childTest.log(Status.SKIP, MarkupHelper.createLabel(pstrStepName, ExtentColor.ORANGE));
	        	childTest.log(Status.INFO, MarkupHelper.createLabel(strMsg, ExtentColor.GREY));		        	
	    		Assert.assertTrue(true);
        	} else {
        		//The Test Case Number with Test Case Name have been skipped
	        	strMsg = pstrTestCaseNumName + " - " + Common.SKIPPED;
	        	parentTest = extent.createTest(pstrTestCaseNumName, pstrTestDesc);
	        	parentTest.assignCategory(pstrTestSuite);
	        	parentTest.log(Status.SKIP, MarkupHelper.createLabel(strMsg, ExtentColor.ORANGE));
	    		Assert.assertTrue(true);
        	}
    		break;
    }        
}

@anshooarora
Copy link
Owner

Thanks. This (the counts) doesn't make sense but I am also not able to repro in any of my tests. Will it be possible to share your report? You can email me at anshooarora at gmail dot com.

@RodNepoLNRisk
Copy link

Hi Anshoo,

I'd like to ask if you were able to check the Test counts and if there's really a possibility that it copies the Steps count or maybe Tests Count and Steps Count are the same, meaning same variable was used? Btw, one more thing, is it ok if we also have Row and Column Totals for the Category section?

Thanks.

@RodNepoLNRisk
Copy link

Hi Anshoo,

I'd like to follow up if you were able to verify the Test count issue?
Thanks.

@anshooarora
Copy link
Owner

Rod, there are way too many tests in the package for me to run through them all and check. I would just like to see the report if possible.

@RodNepoLNRisk
Copy link

Hi,

I've attached 2 classes that call the Extent Reports.
I've also added the java classes for both Extent Reports v2 and v3.

Extent Reports.txt

@anshooarora
Copy link
Owner

Can you attach the report output if possible?

@RodNepoLNRisk
Copy link

category summary totals not displayed for extent report v2 41 2
extent report v3 category discrepancies image2
extent report v3 summary discrepancies image1
tests count is always the same with steps count
tests count the same as steps count even for failed tests

@anshooarora
Copy link
Owner

Sorry I wasn't clear. Can you attach the HTML file itself? I want to view some internals as well..

@RodNepoLNRisk
Copy link

@anshooarora
Copy link
Owner

In version 2, you can select the type of counts you are looking for. If you select childTests and parentTests, you will see a different count there.

Coming to version 3, in your report, I see:

TESTS VIEW

total tests: 50
passed tests:  29
failed tests: 1
others:  20

total steps: 79
passed steps: 29
failed steps: 1
others:  49 
CATEGORY VIEW
// each test that get assigned with category will show up here

AccountDetailReport:  total tests 22, passed 20, failed 1, others 1
Other categories:  all skipped, counts are correct

The counts look correct. Not all tests (eg: 01 - ADR_4_History of All Accounts) have categories assigned to them which is why the counts are not matching up correctly. Its not required for the categories and tests count to match.

@RodNepoLNRisk
Copy link

my concern is the passed tests vs passed steps, how come they're both the same all the time. They both have 29, that's odd because there are some tests with multiple steps, like for the one that failed it had 6 steps and one failed that's why that test failed, but it had 5 other steps that passed. I really think that Passed Tests and Passed Steps might be pointing at the same counter.

@anshooarora
Copy link
Owner

anshooarora commented Mar 20, 2017

They are same in this case because for every passed test, there is a passed step. There are other steps as well, for example INFO but they are counted in others. However, the INFO steps are not present for all tests.

Also, I think we're both talking about the same items but seeing it differently. From the report standpoint, each toggle is a test. The log inside the toggle is a step.

Parent -> Nodes (toggles) -> Logs (steps)

img

@email2vimalraj
Copy link
Collaborator

Hi @anshooarora,

I am able to reproduce the issue reported here. For example, consider the following code:

public static void main(String[] args) {
        // start reporters
        ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("extent.html");

        // create ExtentReports and attach reporter(s)
        ExtentReports extent = new ExtentReports();
        extent.attachReporter(htmlReporter);

        ExtentTest parentTest = extent.createTest("Parent Test");

        // creates a toggle for the given test, adds all log events under it
        ExtentTest test = parentTest.createNode("MyFirstTest", "Sample description");
        test.info("This step shows usage of info(details)");
        test.fail(new RuntimeException("First test failed"));

        ExtentTest test1 = parentTest.createNode("MySecondTest", "Sample description");
        test1.fail(new IllegalStateException("Second test failed"));

        extent.flush();
    }

Here I have 1 Parent Test and 2 Child tests. Refer the following screenshot:

screen shot 2017-03-24 at 11 40 44 pm

The Tests count should be 1 and the Steps count should be 2.

@anshooarora
Copy link
Owner

anshooarora commented Mar 24, 2017

The childTests show up under the Tests section. The logs show up under the Steps section.

ParentTest in such cases is treated as a class so not really a test, but contains tests, such as MyFirstTest and MySecondTest.

For clarity, I can add a similar section as BDD where there are: Features, Scenarios and Steps.

So we can have:

  • Class counts
  • Child Test counts
  • Log counts

@email2vimalraj
Copy link
Collaborator

email2vimalraj commented Mar 24, 2017

Yes, ideally people treat the hierarchy this way, at least in the TestNG world:

Test Suite (parent) -> Test (child) -> Test Method (Grand Child)

There is another case where people wanted to include classes also as follows:

Test Suite (parent) -> Test (child) -> Test Class (Grand Child) -> Test Method (Grand Grand Child)

anshooarora added a commit that referenced this issue Mar 27, 2017
show all charts for classes, tests, steps
if no child tests are available, only show tests and steps charts
fix issue where the logs count does not show up correctly
@anshooarora
Copy link
Owner

Would it be possible to test with the latest commit?

92758f5

It has a new logic to account for class, test, step counts for both standard and bdd style tests.

@RodNepoLNRisk
Copy link

How can I use the latest commit? Is there a new version like 3.0.4?

@anshooarora
Copy link
Owner

anshooarora commented Mar 27, 2017

You can download the files and compile the project;

https://github.com/anshooarora/extentreports-java/tree/92758f5e467ee8f29975120e71dd7aa4f65edf65

@RodNepoLNRisk
Copy link

Hi Anshoo,

I tried to generate the .jar file and copied it to my directory, but I'm getting a NullPointerException error.
Is it ok if you can generate the .jar file and upload it here then i'll use that .jar file. Thanks.

er - nullpointer

@RodNepoLNRisk
Copy link

It's ok now. I was able to generate the .jar

@RodNepoLNRisk
Copy link

Based on the new Counts, it seems like the Classes group is the Test Count, the Test Group is the Step Count and I'm not sure what the Steps total is for, Maybe I need to adjust the Parent and Child.

er-latest results

@RodNepoLNRisk
Copy link

I think it's finally working, so I used the old .jar.
I changed the approach for the Child and Step, and removed the ParentTest.
Thanks Guys for the help.

er - correct counts
er-passed steps
er-passed tests

@anshooarora
Copy link
Owner

So are you using version 3.0.3? The latest commit can be removed?

@RodNepoLNRisk
Copy link

Yes. I'm using v3.0.3. The commit can be removed.
Thanks.

@anshooarora
Copy link
Owner

I will provide an option to choose either strategy, so the default is TEST and the new one from the latest commit is CLASS. Either can be chosen for the report as there will be users as per @email2vimalraj's reply who may want to see this view.

@email2vimalraj
Copy link
Collaborator

email2vimalraj commented Mar 28, 2017 via email

anshooarora added a commit that referenced this issue Mar 28, 2017
usage:

extent.setAnalysisStrategy(AnalysisStrategy.CLASS);
extent.setAnalysisStrategy(AnalysisStrategy.TEST);
@anshooarora
Copy link
Owner

anshooarora commented Mar 28, 2017

made a few updates today, now you will be able to select an AnalysiStrategy:

// version 3.0.4 (upcoming) onwards
// charts will be divided into 3:  Class, Test and Steps (logs)
extent.setAnalysisStrategy(AnalysisStrategy.CLASS);

// standard, as of version 3.0.3
extent.setAnalysisStrategy(AnalysisStrategy.TEST);

02e0b41

@email2vimalraj
Copy link
Collaborator

@anshooarora : I'm running the following code

public static void main(String[] args) {
        // start reporters
        ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("extent.html");

        // create ExtentReports and attach reporter(s)
        ExtentReports extent = new ExtentReports();
        extent.attachReporter(htmlReporter);
        extent.setAnalysisStrategy(AnalysisStrategy.CLASS);

        ExtentTest parentTest = extent.createTest("Parent Test");

        ExtentTest test = parentTest.createNode("MyFirstTest", "Sample description");

        ExtentTest test1 = test.createNode("MySecondTest", "Sample description");
        test1.fail(new IllegalStateException("Second test failed"));

        ExtentTest test2 = test.createNode("Test 3", "Sample description");
        test2.pass("Passed");

        extent.flush();
    }

My AnalysisStrategy is set as Class. I was expecting this:

  • parentTest as Suite which should be reported as 1 failed.
  • test as Test which should be reported as 1 failed again.
  • test1 and test2 as Test Methods which should be reported as 1 passed and 1 failed.

However what I have observed is as follows:

screen shot 2017-03-29 at 10 43 41 pm

Here not sure whether the parentTest or test is considered as Class. And what is the difference between Tests and Steps here.

Also if you see here:

screen shot 2017-03-29 at 10 46 18 pm

The tile cards' title are mismatching. The count of Tests is showing the count of Classes and not much clear on the Steps count.

I guess we need to introduce another strategy called Suite, this should have the following hierarchy:

Suite > Test > Steps

The current Class strategy ideally should have the following hierarchy:

Suite > Test > Class > Steps

@anshooarora anshooarora reopened this Mar 29, 2017
@email2vimalraj
Copy link
Collaborator

@anshooarora : Is it possible to give the user an ability to decide which node has to be a parent, child and grand child?

We can limit the levels to be max 4, because I can't think any use case beyond 4.

So the levels should be:

  • parent
  • child
  • grand child
  • grand grand child

User can set which node can be a parent and so on. If any level is not found, the respective chart and other information should not be shown.

What is your view on it?

@anshooarora
Copy link
Owner

Steps = Logs

From your example above, I see:

  • ParentTest = Class (will contain tests) (1 fail)
  • MyFirstTest = holds child tests for grouping
  • MySecondTest & Test3 = Tests (1 pass, 1 fail)
  • Steps/Logs = 1 Pass, 1 Fail

Does it make sense?

So depending upon how the reporting is being used, ideally, in this strategy, the left side must contain all the classes that are being tested. The interesting thing is, TestNG also implements a concept of suite which is going to throw this strategy out because it adds another level.

Due to this, we can rename:

  • Classes -> Suites
  • Tests -> Classes
  • Steps -> Methods/Tests

Does it sound correct?

@email2vimalraj
Copy link
Collaborator

Yeah, that is why I'm proposing another level called grand grand child. However I'm adding another strategy called Suite and sending you the PR.

Let me see whether I can add another level to it.

@anshooarora
Copy link
Owner

Add a minor change to make the labels dynamic for the chosen AnalysisStategy.

c2720aa

@email2vimalraj
Copy link
Collaborator

email2vimalraj commented Mar 29, 2017 via email

@naveenru
Copy link
Author

Can some one please generate a .jar file with the latest changes and provide link for download.
so that i can test with the latest .jar file

@anshooarora
Copy link
Owner

@naveenru - latest 3.0.4 is now available. Also closing this ticket as ER is now complete.

AnalysisStrategy.

@liu02124091
Copy link

I also get this same concern. I suggest can we Change the name of "Steps" in the result? Honestly it's very confused for the users

@email2vimalraj
Copy link
Collaborator

@liu02124091 : Which version of ExtentReport are you using? This issue had been solved from starting 3.0.4. The current release version is 3.0.5. Could you please upgrade to the latest version and try?

If something is not working as expected, feel free to comment back with steps to reproduce.

@gaurishabh
Copy link

gaurishabh commented May 13, 2017

Hi @anshooarora / @email2vimalraj ,

I have the same concern in this regard. I have one class under which there are 16 TCs. Below is the report which got generated. In a way its hard to understand for other users that how many TC exactly executed and how many are pass or fail.

Can we display number of TC Pass / Fail infront of test name itself because it marked complete Test as fail even though 14 TC are passing and only 2 got failed.

I am open to any other suggestion by which we can display it in a much better way. Please help !

image

@doshipranavs
Copy link

doshipranavs commented Nov 7, 2017

Dear @anshooarora
Can you please advise how I can turn off StepView chart.
It gives wrong impression to management so just want to show Test Chart not step chart.
Also how to set dattime format in newer version of 3.0.2

Tried to search lot but couldnt find anywhere
I would appreciate your help to find solution
Thanks
Regards
PD

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

No branches or pull requests

7 participants