Using PackageIndex in IdeaTestCase unit testing

I have a plugin that uses intelliJ's indexing api,

the plugin logic is depdent on the ProjectIndex scanning capabilities, so I'm running this code:

public class XmlParsingUtilTest extends TestSourceBasedTestCase {

    public void testMyParsing() {
    
        final VirtualFile[] xmlVfToScan = PackageIndex.getInstance(getProject()).getDirectoriesByPackageName("queries", true);
               // the xmlVfToScan is null - since the directory being scanned (Windows 7) is created somewhere in the c:/Users/../AppData/Local/Temp/TestName...
           project.getComponent(RefCollectionManager.class).startScan(xmlVfToScan);

        }
}       

I need to scan my project directory like in a regular plugin run,
or better yet, control the directory being scanned more easily somehow.
Does the overriding the getTestPath will do the trick? is there a better way (or a more right way) to do that?

Eldad.

1 comment
Comment actions Permalink

IntelliJ IDEA's tests usually work by copying test data from your plugin directory to a temp project directory. If you haven't provided any test data to copy, the temp project will be empty.

To specify where the test data is copied from, you need to override the getTestDataPath() method.

0

Please sign in to leave a comment.