boolean (@NotNull JUnitConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { final Project project = configuration.getProject(); final PsiElement element = context.getPsiLocation(); if (!(element instanceof PsiDirectory)) return false; final PsiPackage aPackage = AbstractJavaTestConfigurationProducer.checkPackage(element); if (aPackage == null) return false; final VirtualFile virtualFile = ((PsiDirectory)element).getVirtualFile(); final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project); if (module == null) return false; if (!ModuleRootManager.getInstance(module).getFileIndex().isInTestSourceContent(virtualFile)) return false; int testRootCount = ModuleRootManager.getInstance(module).getSourceRoots(JavaSourceRootType.TEST_SOURCE).size(); if (testRootCount < 2) return false; if (!LocationUtil.isJarAttached(context.getLocation(), aPackage, JUnitUtil.TEST_CASE_CLASS, JUnitUtil.TEST5_ANNOTATION, JUnitCommonClassNames.ORG_JUNIT_PLATFORM_ENGINE_TEST_ENGINE)) return false; setupConfigurationModule(context, configuration); final JUnitConfiguration.Data data = configuration.getPersistentData(); data.setDirName(virtualFile.getPath()); data.TEST_OBJECT = JUnitConfiguration.TEST_DIRECTORY; configuration.setGeneratedName(); return true; }