TestNG, Multiple duplicate listener warnings on implementing multiple listener interfaces

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

TestNG, Multiple duplicate listener warnings on implementing multiple listener interfaces

bipo1980
I have a single Listener class that implements IAnnotationTransformer, IInvokedMethodListener, ITestListener and IReporter.


My Test run successfully BUT i get a warning "[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener".
This warning is shown for every method call i.e. Listener gets called multiple times per test method invocation, and hence the IGNORED duplicate warning.
  •     How to stop this warning from showing?
  •     It is noted that if i remove the IReporter implementation then the warning is gone.
  •     If i create different classes for each listener implementation then the warning is gone.
  •     However, the plan was to have a single class implementing all the listeners. Is it possible?
  •     How to solve this warning? Is this warning something to be concerned about? How can i stop this warning from showing?

Listener Class:

public class RetryListener implements IAnnotationTransformer, IInvokedMethodListener, ITestListener, IReporter {
    .....implemented methods for interface ....
}

Test Class:

public class RetryProvider {
    @Test (dataProvider = "datasource")
    public void Test1(int code, String type, ITestContext context){
        System.out.println("Test1(): " + code + " : " + type);
    }

    @DataProvider(name = "datasource")
    public Object[][] getData(){
        Object[][] data = new Object[3][2];
        data[0][0] = 1;
        data[0][1] = "apple";
        data[1][0] = 2;
        data[1][1] = "mango";
        data[2][0] = 1;
        data[2][1] = "guava";
        return data;
    }       
}

Test Xml:

...<suite name="NGBug Suite">
    <listeners><listener class-name="com.NGtest.RetryListener" /></listeners>
    <test name="NGBug Test"><classes><class name="com.NGtest.RetryProvider" /></classes>
    </test>
</suite>


Test Result:

[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener
[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener
[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener
Test1(): 1 : apple
Test1(): 2 : mango
Test1(): 3 : guava

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TestNG, Multiple duplicate listener warnings on implementing multiple listener interfaces

Cédric Beust ♔-2
Agree, de should only show this warning once.

-- 
Cédric


On Sun, Mar 26, 2017 at 9:00 PM, <[hidden email]> wrote:
I have a single Listener class that implements IAnnotationTransformer, IInvokedMethodListener, ITestListener and IReporter.


My Test run successfully BUT i get a warning "[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener".
This warning is shown for every method call i.e. Listener gets called multiple times per test method invocation, and hence the IGNORED duplicate warning.
  •     How to stop this warning from showing?
  •     It is noted that if i remove the IReporter implementation then the warning is gone.
  •     If i create different classes for each listener implementation then the warning is gone.
  •     However, the plan was to have a single class implementing all the listeners. Is it possible?
  •     How to solve this warning? Is this warning something to be concerned about? How can i stop this warning from showing?

Listener Class:

public class RetryListener implements IAnnotationTransformer, IInvokedMethodListener, ITestListener, IReporter {
    .....implemented methods for interface ....
}

Test Class:

public class RetryProvider {
    @Test (dataProvider = "datasource")
    public void Test1(int code, String type, ITestContext context){
        System.out.println("Test1(): " + code + " : " + type);
    }

    @DataProvider(name = "datasource")
    public Object[][] getData(){
        Object[][] data = new Object[3][2];
        data[0][0] = 1;
        data[0][1] = "apple";
        data[1][0] = 2;
        data[1][1] = "mango";
        data[2][0] = 1;
        data[2][1] = "guava";
        return data;
    }       
}

Test Xml:

...<suite name="NGBug Suite">
    <listeners><listener class-name="com.NGtest.RetryListener" /></listeners>
    <test name="NGBug Test"><classes><class name="com.NGtest.RetryProvider" /></classes>
    </test>
</suite>


Test Result:

[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener
[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener
[TestNG] [WARN] Ignoring duplicate listener : com.NGtest.RetryListener
Test1(): 1 : apple
Test1(): 2 : mango
Test1(): 3 : guava

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...