I'm following this document (and this one, also saw this, and this) to get my plugin testing going, but having trouble achieving my goal.
I've tried a few angles but I keep hitting the wall, mainly due to:
- com.intellij.codeInsight.daemon.impl.HighlightInfo does not expose it's inner "PsiElement psiElement" member, making it cumbersome to try and assert the results of what comes back from calling myFixture.doHighlighting().
- If I try using myFixture.checkHighlighting() with the highlight testing DSL markup, things go sideways as well becuase deep inside the underlying document gets committed and the resulting changes get picked up by my plugin and pollute the test. This is also the case with testHighlighting() since they use a very similar code path.
- Also, even primitive types like Strings are marked with "Cannot resolve symbol 'String'" error when enabling inspections, which pollutes the resulting highlight infos. I suspect this is due to the tests using a mock JDK, which does not actually resolve types. What can be done to overcome this? Using a real JDK causes other problems, as it complains about the XML markup DSL insinde the java files.
- There's also the option of using the com.intellij.testFramework.InspectionTestCase , but this does not give me the fine grained control over what gets highlighted, since in the expected.xml file I seem to be able to only mention the line number, and not the psi element in question.
What would be the way to achieve proper highlighting testing in light of the above mentioned issues?
I would deeply appreciate your help and any words of wisdom!
Thank you in advance,