Module (String newModuleName) { PsiDirectory dir = createDirectory(getTempRootDirectory().getVirtualFile(), newModuleName); String path = dir.getVirtualFile().getPath() + "/" + newModuleName + ".iml"; Module module = WriteAction .compute(() -> ModuleManager.getInstance(getProject()).newModule(path, StdModuleTypes.JAVA.getId())); PsiDirectory src = createDirectory(dir.getVirtualFile(), "src"); PsiTestUtil.addSourceRoot(module, src.getVirtualFile()); return module; }