extent-framework / extentreports-testng-adapter

TestNG Adapter for Extent Framework
http://extentreports.com/docs/versions/4/java/testng.html
Apache License 2.0
50 stars 14 forks source link

TestName is not correctly set when using @beforeMethod annotation in ExtentITestListenerAdapter #17

Closed lgarelli-thefork closed 4 years ago

lgarelli-thefork commented 4 years ago

Hello,

I just updated to ExtentReports 5.0.0 and extentreports-testng-adapter 1.2.0. After updating I noticed a big change in behaviour in the ExtentITestListenerAdapter.

Previously, the name of the test was set correctly to the left of the report as can be seen in the following image:

image

After updating to the latest version, now the name of the before method is the one written to the left (it's repeated 10 times because I'm using 10 parallel threads).

image

I saw in #5 that this was done to avoid a NPE, however I think that the expected behaviour when using the ExtentITestListenerAdapter should be to have the name of the test method at the left of the report (as it was until the version 1.0.7) and not the name of the "beforeMethod" method as now in version 1.2.0.

Is there a way to write the name of the test on the left when using a @beforeMethod annotation and ExtentITestListenerAdapter ?

Is there a way to skip this createMethod here?


    @Override
    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
        if (method.getTestMethod().isBeforeMethodConfiguration()) {
            createdMethodBeforeInvocation = true;
            ExtentTestManager.createMethod(testResult);
        }
    }
anshooarora commented 4 years ago

@lgarelli-thefork This change should not have been merged.

Please check with 1.2.1-SNAPSHOT. linky

lgarelli-thefork commented 4 years ago

Thanks for your prompt response @anshooarora ! Well, I can wait for the official 1.2.1. Any possible release date?

anshooarora commented 4 years ago

Since this change reverts back to the original code, I can release in the next few mins. Can you confirm this reverts back to the pre-#5 view?

lgarelli-thefork commented 4 years ago

@anshooarora it works!

image

anshooarora commented 4 years ago

Awesome, thanks! Pushing release to nexus now.

anshooarora commented 4 years ago

Its live now https://oss.sonatype.org/#nexus-search;quick~extentreports-testng. Generally takes a few hours to reflect on mvnrepository/search.maven. Cheers

lgarelli-thefork commented 4 years ago

thanks a lot!