Test example not working

Hi,

I want to develop an Idea plugin but i'm facing what is for me a major issue (ie I cant unit test my dev).
I looked into the Community Edition for samples and i found the "conditonalOperatorConvertor".

After many tries,I haven't been able to make the test work, I always get the error : "java.lang.AssertionError: com.intellij not found; platform prefix is null".
Am I missing something? I'm running IDEA 11.1.3.

I searched in a lot of open source plugins but I haven't found any UT.

Regards,
Michaël

7 comments
Comment actions Permalink

The good news is that I found someone with exactly the problem I'm having.  I'm going through the doc for plugin development and get the same error as Michaël.  I'm using Idea 11.1.3 and unit testing is a requirement.

The bad news is the no one has answered him, yet.  Be aware that the return on your investment to answer his question just doubled.

Michaël, I'd appreciate anything you found to resolve this problem since you posted it.

Rob

Update:

I found a solution: add -Didea.platform.prefix=Idea to the JVM arguments in the run configuration for the test.  There will be at least one more problem before you can get the test to work.  I've written some notes at http://robconaway.blogspot.com/2012/11/developing-intellij-idea-plugins.html.

0
Comment actions Permalink

Hi Rob,

Sorry to reply so late, but I gave up testing the plugin, therefore I gave up writing the plugin :).

I recently found this: http://confluence.jetbrains.com/display/IntelliJIDEA/Tests+Prerequisites and I'm retrying to make things work.

Hope this will work now, I'm still getting some errors but as soon as I have a green test I'll let you know.

Regards,

Michaël

0
Comment actions Permalink

Hi,

I know this thread is a little bit outdated, however it took me a non-trivial amount of time to figure this out so let's keep it for future reference in case someone stumbles upon this:

I was struggling to make my own Intellij plugin tests work in the maven/surefire environment and following surefire setting did the trick for me:

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <useManifestOnlyJar>false</useManifestOnlyJar>
                    <useSystemClassLoader>true</useSystemClassLoader>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${java.home}/../lib/tools.jar</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>

In particular:

  1. The default useManifestOnlyJar=true is not compatible with the classpath plugin discovery mechanism. According to docs useSystemClassLoader=true is then manadatory when manifest jar is switched off.
    • This particular setting got me rid of the "com.intellij not found; platform prefix is Idea"
  2. Maven uses JRE while the Intellij test framework somehow references JDK libraries.
    • This particular setting got me rid of the "java.lang.NoClassDefFoundError: com/sun/jdi/Value"


Regards,
Vojta

0
Comment actions Permalink

Hi there,

Out of curiosity is your plugin currently open source?

I had tried to integrate my tests with Maven but I had no luck; I put this down to the custom configuration runner which calls IntelliJ's Main JUnit test runner.
But if you're saying this is possible without calling their main method, i'd definitely like to see that in action :)

Alan

0
Comment actions Permalink

Hi Alan,

I have just started with this task of adding the tests. I will post the link once the tests are fully functional. There are additional challanges that I need to tackle that are not related to Intellij platform.

Except for the configuration I posted and the need to reference the whole Intellij runtime (i.e. all jars in IDEA_HOME/lib/), there was no real blocker. I'm even using the Spring Junit runner from spring-test and it works without a hitch (or seems to at least).

Regards,
Vojta

0
Comment actions Permalink

Hi Alan,

It's been a long time, but in case you are still interested, here is the details I promised.. In the following project:

   https://github.com/janotav/ali-idea-plugin

I use use maven to build & run tests. It's still work in progress but it should give you the idea...

Regards,
Vojta

0

Please sign in to leave a comment.