Testing framework support plugin

I’m developing a framework support plugin.

For some functions of the plugin, I need to read annotations from PsiClass, such as “javax.persistence.Entity” or framework-specific ones.

My problem is that annotation in source file added by myFixture#copyFileToProject has name “Entity” instead of “javax.persistence.Entity”. I assume that this is due to the lack of dependency on javax:javaee-api:7.0.

Is this is possible to add the dependency to test project, or open the real gradle project in a test environment, to make it work?

1
3 comments

I'd suggest just to add required classes via `com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture#addClass` and ensure that correct package statement is used. Adding dependency to the test means that a test can't be light anymore and thus the startup time will be much higher

Anna

1

Thanks for the answer.

It works, but I have too many classes to add in this way.

Installation time does not matter in my case, so I’ll be interested in another way if it exists.

0

you may use `com.intellij.testFramework.PsiTestUtil#addLibrary(com.intellij.openapi.module.Module, com.intellij.openapi.roots.ModifiableRootModel, java.lang.String, java.lang.String, java.lang.String...)` to attach library to the project.

1

Please sign in to leave a comment.