Community
Participate
Working Groups
Build Identifier: I20100608-0911 resolveConstantExpressionValue() returns null if the constant value is inherited from a base class but works as expected when that constant value is in the same class as the node. Reproducible: Always Steps to Reproduce: I have an annotation that takes an array of strings: @Test(groups = "a") If I declare this string in a static field of a base class instead: public class A { public static final String NAME = "a"; } public class B extends A { @Test(groups = NAME) } then calling resolveConstantExpressionValue() on the node that represents the attribute (a SimpleName) returns null. If I move the field into the same class the annotation is located, resolveConstantExpressionValue() returns the expected value ("a"): public class B { public static final String NAME = "a"; @Test(groups = NAME) }
Will investigate.
So you have no declaration (field, method, type) behind the annotation? public class B extends A { @Test(groups = NAME) }
Right now I cannot reproduce the failure. Could you please send me a small project that shows the problem ? Thanks.
In the case: public class A { public static final String NAME = "a"; } public class B extends A { @Test(groups = NAME) } Are you using A from source or from binaries when you create the DOM for B?
I tried with A from source or from binary and it worked in both cases. I cannot reproduce the null case. Would it be possible for you to try a newer build ?
Hi Olivier, Yes, let me try a newer build. Do you have one to recommend?
Olivier, I just tried with the latest stable Indigo and I'm still seeing the problem. How to reproduce: - Install the TestNG Eclipse plug-in (http://github.com/cbeust/testng-eclipse) - Set a breakpoint in AnnotationVisitor:93: else if (value instanceof SimpleName) { Object boundValue = value.resolveConstantExpressionValue(); addGroup(boundValue.toString()); } - Run the plug-in, create two classes A and B as shown above (the base class defines the static final String, the subclass defines a method with @Test(groups = A) - Right click on the class, "Run as..." / "TestNG" - Observe that boundValue is null in line 93 Let me know if you need more help in reproducing this problem.
(In reply to comment #7) > - Run the plug-in, create two classes A and B as shown above (the base class > defines the static final String, the subclass defines a method with > @Test(groups = A) Could you please describe how you set up the two classes and the project in which they belong? Would it be possible for you to attach such a test project ? I tried the steps and I still get a right value.
(In reply to comment #8) > (In reply to comment #7) > > - Run the plug-in, create two classes A and B as shown above (the base class > > defines the static final String, the subclass defines a method with > > @Test(groups = A) > Could you please describe how you set up the two classes and the project in > which they belong? > Would it be possible for you to attach such a test project ? > > I tried the steps and I still get a right value. When I run the class B, it doesn't find any test to run, but it reaches the breakpoint on line 93.
Cedric, I am missing something to reproduce this issue. Would it be possible for you to provide a small project that exhibits the problem? As soon as I can reproduce, I'll work on it to get it fixed. Ideally for M3. Thanks.
Hi Olivier, I can't reproduce the issue on my laptop (I originally found it on my desktop, as did the TestNG user that reported it in the first place). I'm away from my desk for the week so I suggest we close this issue for now and next week when I'm back at my desk, I'll confirm it doesn't work there and I'll reopen it with an attached project and maybe a bit more clue as to why it's only failing in certain conditions. Thanks for your help, Olivier.
Ok. Closing as WORKSFORME. Please reopen if you get it again or have more clue on what is going on.
Verified for 3.7M3 as per user comment
(In reply to comment #11) > I'm away from my desk for the week so I suggest we close this issue for now and > next week when I'm back at my desk, I'll confirm it doesn't work there and I'll > reopen it with an attached project and maybe a bit more clue as to why it's > only failing in certain conditions. Any update on this ?
Hi Olivier, Sorry, I've been sidetracked into oblivion and I haven't had the time to get back to this. I have an open TestNG bug about this so I will get back to it eventually :-)
*** Bug 338390 has been marked as a duplicate of this bug. ***
Reopening for further investigation once a test case from bug 338390 is providedé
Please provide a test case to fix this bug.
hi, i tried to implement a simple maven project with some testng tests, but somehow I cannot reproduce this bug with a new project. This is reproducable (not always, but surely sometime after 30 minutes of work), so I do not know, how I could provide a testcase for this, sorry:(.
(In reply to comment #20) > This is reproducable (not always, but surely sometime after 30 minutes of > work), so I do not know, how I could provide a testcase for this, sorry:(. Would it be possible for me to get a hold onto the workspace that creates the problem ? This seems to be the easiest way to fix this.
(In reply to comment #21) > (In reply to comment #20) > > This is reproducable (not always, but surely sometime after 30 minutes of > > work), so I do not know, how I could provide a testcase for this, sorry:(. > Would it be possible for me to get a hold onto the workspace that creates the > problem ? > This seems to be the easiest way to fix this. Hi, sorry, that is absolutely not possible, I'm really sorry, but I am not allowed to publish anything from my project:(.
Closing as WORKSFORME. Once you can provide a reproducable test case, I'll investigate.
Verified for 3.7M7 using build I20110421-1800