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).

0
2 comments
Avatar
Permanently deleted user

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

Can I reference a maven dependency JAR in my virtual test project ?

Or must I store the JAR in my project - I am unable to add it to my test project yet.

 

0

Please sign in to leave a comment.