The Listener instantiation and lifecycle management is not done by Spring but its being managed by TestNG. That is perhaps why your dependency injection via the @Autowire doesn’t work and you see NPE.
So you can perhaps do something like this :
Define an interface within which you expose all end-user actions via methods. Have all your classes (the likes of your Class A) implement this interface and define the required behavior.
Now within your TestNG Listener (ITestListener implementation), you can do something like this :
public class Testlistener implements ITestListener {
@Override
public void onTestStart(ITestResult result) {
Object instance = result.getMethod().getInstance();
if (instance instanceof Operations) {
((Operations) instance).print();
}
}
}
interface Operations {
void print();
}
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
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...@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.