library depndency in InspectionTestCase

I use InspectionTestCase to test inspection and I want to add library
dependency to the module that is used in that testcase. I tried code like
this:

ModuleRootManager manager = ModuleRootManager.getInstance(module);
ModifiableRootModel rootModel = manager.getModifiableModel();
Library jarLibrary = rootModel.getModuleLibraryTable().createLibrary();
Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel();
libraryModel.addJarDirectory("/path/to/libs", false);
libraryModel.commit();
rootModel.commit();

but it doesn't change rootModel.getOrderEntries() result. If I call
rootModel.addLibraryEntry(jarLibrary) test fails at
LibraryOrderEntryImpl.]]>(LibraryOrderEntryImpl.java:54).

1 comment
Comment actions Permalink

Dmitry Kandalov wrote:

I use InspectionTestCase to test inspection and I want to add library
dependency to the module that is used in that testcase.


PsiTestUtil#addLibrary does it.

0

Please sign in to leave a comment.