void () { WriteAction.run(() -> { myModuleRootListener.reset(); ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(() -> { for (int i = 0; i < 10; i++) { ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel(); try { File dir = createTempDir("src-" + i); VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir); model.addContentEntry(vDir); } catch (IOException e) { throw new RuntimeException(e); } model.commit(); assertEquals(1, myModuleRootListener.beforeCount); assertEquals(0, myModuleRootListener.afterCount); } }); myModuleRootListener.assertEventsCount(1); }); }