-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How come TestNG listeners are global? #3112
Comments
@danielgil82 - Thanks for adding up this issue here. The current behaviour of TestNG is that, all listeners are treated as "global" and we don't have the notion of "scoped" listeners in TestNG yet. When I say "scoped" I mean something like below:
The other thing we need to also consider is how do I allow a user to specify this scope for me (Without breaking backward compatibility of-course). Some points to ponder would include the following
Please share your expectations around these as comments so that the scope of this issue can be made clear. |
|
I think it's better suppose to be called per TestClass, I mean if a class wants to trigger a listener, then let it trigger the listener, That sounds good, and also, it could be better if you could add a disable flag on the listener level,
|
Expected behavior
Whenever one doesn't add listener on class level, a listener still gets triggered.
Test case sample
I'm adding this as following talk with @krmahadevan.
https://stackoverflow.com/questions/78287583/why-custom-listener-is-called-when-i-dont-attach-it-to-testclass-not-via-annot
In concise I have a logging listener, that I added to one of my test classes.
And didn't conclude this listener to the second test class.
My LoggerListener implements ITestListener, IClassListener. The thing is that the second test class enters onBeforeClass and its onAfterClass, now It's surprising because, i'm asking my self what's the purpose of @listeners then,
In ITClassTestB there is no LoggerListener on the class level.. and it still enters where I said .
I'll add snippets of code, so you could see how to reproduce..
Xml file:
Contribution guidelines
The text was updated successfully, but these errors were encountered: