TestListener is being lost when implenting both IClassListener and ITestListener #2752
Closed
2 of 7 tasks
Labels
Milestone
TestNG Version 7.0.0 and 7.5
How to reproduce?
Expected behavior
All tests that match the skip conditions are skipped when tried to be executed
Actual behavior
Only the first one is skipped.
Is the issue reproducible on runner?
Test case sample
Here you have a small IntelliJ project containing two testng xmls, one has the listener explicit in the suite, the other one doesn't:
https://github.com/jmoreira18/TestNG-ClassListener-issue-demo
Provisional workarounds
Code comments
I've been debugging the TestNG library in my project and this are a few things I found:
This continue (inside the if) is skipping the TestListener, even though it's both implementing the ITestListener and IClassListener
I noticed this previous if -> continue, was added due to a fix, basically, trying not to add a ClassListeners two times.
I propose to remove that continue from there and put that check on addListener(ITestNGListener listener) instead:
And inside addListener(ITestNGListener listener), all the adds should check that the listener is not already in each one of the lists and if not, add it (like it's done in IClassListener):
(Although this might not be needed, cause put basically replaces items if they already exist)
Thanks in advance!
The text was updated successfully, but these errors were encountered: