[testng-dev] ITestNGListenerFactory

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[testng-dev] ITestNGListenerFactory

kelvsyc
Right now, I have a bunch of ITestNGListeners that I need to have created through Guice.  It looks like I can use ITestNGListenerFactory for this.  However, looking at the sources, it seems that ITestNGListenerFactory is a bit clunky due to a number of factors, and I am wondering if that's intentional, or just old code:

* Due to the way TestRunner works, any class that implements ITestNGListenerFactory must also implement ITestNGListener.
* If that's the case, then I could be able to specify it just like any other ITestNGListener, except that adding the listener via testng.xml or command-line or other equivalent does not work. Things either get ignored or exceptions get thrown because ITestNGListenerFactory is not an ITestNGListener subclass despite the relationship above.
* The Javadocs seem to conflict with how I can pass in an ITestNGListenerFactory.  Javadocs say that only one instance of any class implementing ITestNGListenerFactory may be present at any point in the suite.  The suggested use of @Listeners seems to indicate that two unrelated test classes may have different ITestNGListenerFactory instances.
* The code that detects the presence of an ITestNGListenerFactory does not appear to take idempotent declarations well.  For instance, if a superclass declares an ITestNGListenerFactory class, and a subclass declares the same ITestNGListenerFactory class, that appears to be an error.

In short, ITestNGListenerFactory is basically well short of, say, IObjectFactory when it comes to initialization of test components.

Since Guice is so integrated into TestNG, I'm wondering if it is at all possible to have one suite-wide Injector that covers both the instantiation of test classes and the instantiation of TestNG listeners.

--
You received this message because you are subscribed to the Google Groups "testng-dev" 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 http://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.