findSuperMethods() is not working as expected with TestMode.FULLY_QUALIFED

61 views
Skip to first unread message

Dayakar

unread,
Nov 8, 2021, 2:52:56 PM11/8/21
to lint-dev
Hello all,

We have encountered a test failure while working with the TestMode.FULLY_QUALIFIED. We have some test cases where we look at the presence of annotations in the method parameters and the return types. To achieve this, we are using the findSuperMethods() from the PsiMethod interface to get the super methods to look at the super method's annotations.

For the test case, we have a Java class, where we have an interface with a method that has @NonNull annotation. This interface is implemented by a class where the overriden method doesn't have the annotation. The test case is supposed to throw a lint warning.

As the current test file is a Java file, the PsiMethod's implementation is calling into PsiSuperMethodImplUtil.java where the findSuperMethods(*) call is working as expected in all the cases except when the TestMod is FULLY_QUALIFIED. I tried to trace it till findSuperMethodSignatures(*) and I got an empty array from the SuperMethodsSearch.search() call when the TestMode is FULLY_QUALIFIED.

Can I get some help with this.

Thanks
Dayakar



Tor Norbye

unread,
Nov 24, 2021, 2:21:58 PM11/24/21
to lint-dev
The test failure should show you the modified test source (where it has taken your original source and has replaced most of the unqualified references with fully qualified references). You can take a look at that and see whether the test looks like a reasonable scenario you want to cover. If not, you can simply ignoreTestModes(TestMode.FULLY_QUALIFIED) -- there are occasional scenarios where test modes don't apply so skipping them is totally fine. But when you look at the modified test mode you can either spot whether something looks wrong (e.g. a bug in the test mode code -- if so, let us know; for example, the whitespace test mode was incorrectly inserting a space between the label name and the "@" until recently), or narrow it down to one particular corner case in the test and debug through that.

-- Tor

Reply all
Reply to author
Forward
0 new messages