Running Annotator unit test gives Cannot resolve symbol 'String' for basic JDK classes
Hi
I have problem with testing my Annotator because checkHighlighting report errors on basic JDK classes like 'String'.
Is there way to setup the LightCodeInsightFixtureTestCase to use a JDK it run the inspecting test or what are my options?
public void testAnnotatorUnknownOptionWithConsumerAnnotationValidation() {
myFixture.configureByText("AnnotatorTestData.java", getJavaUnknownOptionsConsumerAnnotationTestData());
myFixture.checkHighlighting(false, false, true, true);
}
private String getJavaUnknownOptionsConsumerAnnotationTestData() {
return "public class MyRouteBuilder extends RouteBuilder {\n"
+ " @Consumer(file:test?allowNullBody=true&<error descr=\"Unknown option\">foo</error>=bar);"
+ " public void onCheese(String name) {}"
+ " }";
}
The full test case can be viewed here https://github.com/davsclaus/camel-idea-plugin/blob/master/camel-idea-plugin/src/test/java/org/apache/camel/idea/annotator/CamelAnnotatorTestIT.java
Thanks
Flemming
请先登录再写评论。
Please set property idea.home.path property correctly, it must point to IJ community sources to find corresponding mockJDKs (see IdeaTestUtil)
I'm still not able to get it work, still the same issue
I follow the SDK guide "Tests Prerequisites" http://www.jetbrains.org/intellij/sdk/docs/tutorials/writing_tests_for_plugins/tests_prerequisites.html and set the idea.home.path to point to my IJ
-ea
-Xbootclasspath/p:../out/classes/production/boot
-XX:+HeapDumpOnOutOfMemoryError
-Xmx512m
-XX:MaxPermSize=320m
-Didea.system.path=target/test-system
-Didea.config.path=target/test-config
-Didea.test.group=ALL_EXCLUDE_DEFINED
-Didea.load.plugins.id=org.apache.camel
-Didea.home.path="C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community Edition 2016.3.2/"
it must point to checked out IJ community sources, not the installation
Thanks, I missed that part in your previous comment
It's works now :-)
The code news it's working for JDK classes now, but after that I got the same problem for 3 party libraries.
public void testAnnotatorCamelPredicateValidation() {myFixture.configureByText("AnnotatorTestData.java", getJavaWithCamelPredicate());
myFixture.checkHighlighting(false, false, false, true);
}
I have added the camel-core lib to myModule, but it still fail with "Cannot resolve symbol" for Apache Camel classes
How do you make it aware of 3 party libs in my test?
Thanks
Please use com.intellij.testFramework.PsiTestUtil to add libraries and perform other test project modifications.
Thanks!!!!
With the insight your provided, I was able to solve it by adding the library in the "getProjectDescription" method