How to use JavaCodeInsightFixtureTestCase



I've been trying to create a very simple test case for my plugin but no luck so far.

This is my test case:

public class FormatterActionHandlerTest extends JavaCodeInsightFixtureTestCase {
    public void testBasic() {
        Editor editor = myFixture.getEditor();

When I run it I get two problems:

1) editor variable is always null
2) junit.framework.AssertionFailedError: Cannot find source file: ''. getTestDataPath()='C:/Andre/.IntelliJIdea/system/plugins-sandbox/test'. getHomePath()='C:/Andre/.IntelliJIdea/system/plugins-sandbox/test'.

My project structure looks like this:

My Plugin
+--- src
+--- testSrc
+--- testData

I tried to override getBasePath() and getTestDataPath() methods and use PluginPathManager.getPluginHomePath() but it didn't work either...   

I'm running the tests from my plugin project... Am I missing something?


1 comment

Hi Andre,

I know this does not solve all of your problems, but I recently ran into the same problem. I was able to work around it by using

myFixture.addClass("public class MyClass { ... /* your code */ }");

at the beginning of a test method that uses that class, instead of trying to load it from my test resources.


Please sign in to leave a comment.