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
testng 6.9.12 start to post 3 org.testng.ITestListener#onTestStart events for one test method #1084
Comments
Actually the problem is that my listener implements multiple interfaces (ISuiteListener, IResultListener, IInvokedMethodListener) and is registered multiple times as suite listener, etc. |
Yep, I can try to split my listener in multiple classes, should I do that? The main problem with it that the old IDEA versions won't be compatible with new testng :/ |
No need to split into multiple classes: just register it only once with Note that only But adding the same listener many times is not supposed to call it many times. Will try to reproduce it, or maybe you can propose use a new test case that shows the issue? https://github.com/cbeust/testng/tree/master/src/test/java/test/listeners |
It didn't work with addListener(Object) because it detects the first 'instance of' and do not proceed further (previously that was needed to get the rest of the events). With the last version it works but we need to support previous versions as well. Please note that we can't use addListener(ITestNGListener) for the same compatibility problem. Looks like whether you replace list with LinkedHashSet or I need to split listeners to different classes. |
Yes, I will try something like that.
Ok, I take the point. Maybe https://github.com/testng-team/testng-remote/ is a good starting point as it provides some backward compatibilities with previous testng version for the testng-eclipse project. |
That was our previous approach and we had a lot of compatibility issues as the protocol should be the same on both sides, so IDE should bundle exactly the same version user uses to tests. And suppose a user has different testng versions for different tests or has different projects with different versions. That simply doesn't work so we end up with our own protocol on both sides so user always has compatible protocol. |
You should exchange with @missedone because I think it has exactly the same needs and fixes most of them now. |
But don't worry, it is not yet planned to break the API ;) |
hi @akozlova
with the new protocol anyway, let's start the discussion in a new thread as you like. (don't want to pollute current one 😄 ) |
Guys, now we have one common protocol between all tests (junit, testng, javascript, python, etc) and we are quite happy with it. In order to adapt new remote protocol for testng I would have to translate it into our protocol, I don't think that it's feasible. Please make addListener(Object) not deprecated and IDEA would be happy. Thanks |
@akozlova And what about something like: public static void addListener(TestNG tng, Object listener) {
Method addListener;
try {
addListener = tng.getClass().getMethod("addListener", ITestNGListener.class);
} catch (NoSuchMethodException e) {
try {
addListener = tng.getClass().getMethod("addListener", Object.class);
} catch (NoSuchMethodException e1) {
throw new IllegalArgumentException("No addListener method found", e1);
}
}
try {
addListener.invoke(tng, listener);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
} |
I have a lot of reflection there already, I can add another one, no problem. |
Sure, I will. |
@juherr and please add a comment to that method to make it clear that IDEA needs it. Thanks! |
Fix issue #1084: listener registration
Thanks! |
Works fine with 6.9.11.
link to the initial issue: https://youtrack.jetbrains.com/issue/IDEA-158214. (IDEA treats each onTestStarted event as new test method and creates a node for it in the tree)
The text was updated successfully, but these errors were encountered: