Heavyweight IDEA testing

Since I didn't expect what I was dreaming about in an earlier post to this forum about lightweight testing to actually be possible now, I started investigating heavyweight testing.
I setup a directory testdata with three module directories t1, t2 and t3.
Then I created the following

 fixtureBuilder =

    fixtureBuilder.addModule(JavaModuleFixtureBuilder.class).addContentRoot(testdataDirPath + "/t1");
    fixtureBuilder.addModule(JavaModuleFixtureBuilder.class).addContentRoot(testdataDirPath + "/t2");
    fixtureBuilder.addModule(JavaModuleFixtureBuilder.class).addContentRoot(testdataDirPath + "/t3");


Unfortunately afterwards there is only one module called "0" with a virtual - non-existing - module file 0.iml that references all three content roots. It also doesn't seem to be possible to rename the module. There is no way to obtain a ModifiableModuleModel before setUp() is called on the fixture. ModifiableModuleModel has a method renameModule.

I then threw it all away and started anew. I still create the fixture as shown above, but now I have also created three module files t1.iml, t2.iml and t3.iml and put them in their module directories t1, t2 and t3.
Now I call setUp() on the fixture, open a write Action with ApplicationManager.getApplication().runWriteAction, obtain a ModifiableModuleModel and load each of the three module files with loadModule.
Now I get three modules t1, t2, t3, but non of them has a content or source root.
The module files look all the same:



Is it just not possible to create a fixture that uses more than one module or what's the problem here?


Comment actions Permalink

OK besides the ModifiableModuleModel I now also fetch a ModifiableRootModel for each module and add content and source roots via addContentEntry on the root model and addSourceFolder on the created content entry.
New problem now. The contents of the source folders isn't analyzed: PsiManager.findPackage() or PsiManager.findClass() doesn't find anything. Do I also need to manually activate some trigger?
I use ProjectRootManager.multiCommit(ModifiableModuleModel, ModifiableModuleRootModel[]) to commit all those changes I make.
Another strange thing I noted is that even though each module file specifies a facet, it doesn't exist after loading the module via ModifiableModuleModel.loadModule() and committing the changes. So I suspect there is a trigger that needs to be pushed to really load a module.


Comment actions Permalink

OK, I found the answer to my question myself.
Actually the source folders are analyzed. The whole content is then cached. While IDEA updates the caches in a normal environment, it never does that for test data.
At first it's a bit inconvenient. After changing anything in the test data you have to delete ]]>/test/system.
But it makes perfectly sense. Test data doesn't change that often and with disabled cache updating we a bit of performance for the test runs.
So this is actually a great feature. The only problem is that it isn't documented.


Please sign in to leave a comment.