Testing custom inspection plugin

Hry I'm trying to test my plugin which replaces the use of deprecated class with supported replacement and adds an import statement. I'm using
To test my plugin I'm extending  LightCodeInsightFixtureTestCase.

public void testApplyFix() {
    List<IntentionAction> availableQuickFixes = myFixture.getAllQuickFixes("InspectionBefore.java");
    for (IntentionAction quickFix : availableQuickFixes) {

Which should find a deprecated class and replace it with supported one. The problem is the method fails with

java.lang.IllegalArgumentException: Argument for @NotNull parameter 'refClass' of com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.addImport must not be null
     at com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl.addImport(JavaCodeStyleManagerImpl.java)
     at com.intellij.codeInspection.MyInspection$MyQuickFix.applyFix(MyInspection.java:124)
     at com.intellij.codeInspection.MyInspection$MyQuickFix.applyFix(MyInspection.java:99)
     at com.intellij.codeInspection.ex.QuickFixWrapper.invoke(QuickFixWrapper.java:86)

Apparently it is unable to find the package of the supported class. The question is where should I place the package with the supported class so that it can be found by a plugin under test?
I've tried adding the package with the supported class to mock jdk i'm using to test my plugin but it doesn't work. I've also tried to add it in multiple directories in my plugin folder.
It's worth noting that if I change the supported class to something in jdk for instance java.text.DecimalFormat the method works.
I have already tested inspection highlighting so I know nothing's wrong with my configuration

1 comment
Comment actions Permalink

I've found a solution. You have to call this method

myFixture.copyDirectoryToProject("sourceDirectory", "targetDiretoryInProject");

Please sign in to leave a comment.