RunConfiguration (final String packageName) { PsiPackage aPackage = JavaPsiFacade.getInstance(myProject).findPackage(packageName); assertNotNull(aPackage); PsiDirectory[] directories = aPackage.getDirectories(GlobalSearchScope.moduleTestsWithDependentsScope(myModule)); assertTrue(directories.length > 0); JUnitConfiguration configuration = new JUnitConfiguration("dir", myProject); JUnitConfiguration.Data data = configuration.getPersistentData(); data.TEST_OBJECT = JUnitConfiguration.TEST_DIRECTORY; data.setDirName(directories[0].getVirtualFile().getPath()); configuration.setModule(ModuleUtilCore.findModuleForPsiElement(directories[0])); return configuration; }