Failing plugin tests with latest EAP (2019.2.*) -> NoClassDefFoundError
Hi,
I am having a Gradle setup for my CSV Plugin (https://github.com/SeeSharpSoft/intellij-csv-validator), making use of Travis CI for testing against several IntelliJ versions (https://travis-ci.org/SeeSharpSoft/intellij-csv-validator/builds/550637738).
Everything works fine, but lately when running against the latest EAP version, all tests are failing with a "java.lang.NoClassDefFoundError: com/intellij/psi/PsiElementFactory" exception. My gut feeling is, that the concrete exception might be only an effect of some underlying changes to the IntelliJ TestFramework, e.g. due to renaming of classes like "LightPlatformCodeInsightFixtureTestCase
(renamed to BasePlatformTestCase
in 2019.2)" (http://www.jetbrains.org/intellij/sdk/docs/basics/testing_plugins/tests_and_fixtures.html)
However, I couldn't find any other threads or hints about this issue/topic. Are there any announced breaking changes? How to resolve this? And as a bonus: How to handle my test-setup for the particular case of a test class name change? I'd like to stay back-compatible with at least two major versions.
Thanks, Martin
请先登录再写评论。
This seems like most likely reason https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
Thanks - thats it! Now I get a lot of real exceptions that I have to validate, but that's another cup of tea...
However, the "bonus question" becomes quite important now: How do I keep the backward compatibility of my tests? The plugin itself does not require 'Java' related functionality, it works across all Jetbrains platforms.
However, I am currently using an Intellij IDEA as 'version' (for gradle plugin) for testing, which has 'java' defined as essential plugin now. Not adding 'java' as a plugin in the gradle setup results in "com.intellij.ide.plugins.PluginManagerCore$EssentialPluginMissingException: Missing essential plugins: com.intellij.java".
So which version can I use for the tests that do not have any essential plugins requirements? And what is the actual advice for backward compatible test setup regarding the mentioned deprecation of 'LightPlatformCodeInsightFixtureTestCase' or 'LightCodeInsightFixtureTestCase'?
1) com.intellij.psi.PsiElementFactory IS Java-related, whether you use it for manipulating Java PSI or not. See its javadoc.
2) The deprecation of the test base classes is not a "real" problem as they extend the new base classes. Replacements are noted in their javadocs.
Please note that using LightCodeInsightFixtureTestCase does require Java, so you should use
LightPlatformCodeInsightFixtureTestCase
instead everywhere.Oh yes, I know about the com.intellij.psi.PsiElementFactory - I learned about it already some time ago (https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000678690-com-intellij-psi-PsiElementFactory-not-available-in-PhpStorm-SDK-EAP-) and removed it completely from my code. The dependency seems to be within the 'LightCodeInsightFixtureTestCase', but I will replace it with 'LightPlatformCodeInsightFixtureTestCase'. Thanks for the hint about the deprecation!
So just one question remains: Which IDE version can I use for test & development that does NOT (EDIT) have any essential plugin requirements?
I don't understand this question, what problem do you want to solve?
> So just one question remains: Which IDE version can I use for test & development that does have any essential plugin requirements?
ERROR: Missing essential plugins: com.intellij.java
com.intellij.ide.plugins.PluginManagerCore$EssentialPluginMissingException: Missing essential plugins: com.intellij.java
at com.intellij.ide.plugins.PluginManagerCore.checkEssentialPluginsAreAvailable(PluginManagerCore.java:1484)
at com.intellij.ide.plugins.PluginManagerCore.initializePlugins(PluginManagerCore.java:1495)
at com.intellij.ide.plugins.PluginManagerCore.initPlugins(PluginManagerCore.java:1681)
at com.intellij.ide.plugins.PluginManagerCore.getLoadedPlugins(PluginManagerCore.java:140)
at com.intellij.idea.IdeaTestApplication.lambda$createInstance$0(IdeaTestApplication.java:97)
...
EDIT: This error occurs when the test framework tries to start up the headless IDE, and 'IC' requires that 'java' plugin is defined in the plugins section of the gradle plugin - which works fine for 2019.2.* but obviously not for prior versions (as the comment from your first link shows).
I already figured out that using type 'PC' (PyCharm Community) in the gradle plugin (https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties) does not have any essential plugins.
What is your minimum required "since-build" for your plugin? It seems it should be lower, still you run against 2019.2?
My since-build is "163.10154", but I have one CI test build also run against the latest EAP to early discover and solve problems like this one.
Thanks, this is indeed a situation where IDE tried to load essential plugins despite not needing them. Fix was just backported to 192 branch.
Thanks Yann! Due to your quick and profound help I have stable CI tests running (again) against all IDE types/versions that I intended to support. For the latest EAP version I switched to PyCharm, which I should have done earlier to discover those "hidden" Java-related dependencies in my tests.