TestNG, Multiple duplicate listener warnings on implementing multiple listener interfaces

239 views
Skip to first unread message

bipo...@gmail.com

unread,
Mar 27, 2017, 12:00:53 AM3/27/17
to testng-users
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

Cédric Beust ♔

unread,
Mar 27, 2017, 12:13:37 AM3/27/17
to testng...@googlegroups.com
Agree, de should only show this warning once.

-- 
Cédric


--
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 testng-users+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages