Module (Module moduleA, DependencyScope scope) { Module moduleB = createModule("b" + ".iml", StdModuleTypes.JAVA); ApplicationManager.getApplication().runWriteAction(() -> { VirtualFile rootB = myFixture.findOrCreateDir("b"); VirtualFile outB = myFixture.findOrCreateDir("out"); ModuleRootModificationUtil.addDependency(moduleA, moduleB, scope, false); PsiTestUtil.addSourceRoot(moduleB, rootB); PsiTestUtil.setCompilerOutputPath(moduleB, outB.getUrl(), false); }); return moduleB; }