boolean (@NotNull final TestClassFilter testClassFilter, @Nullable final Module module, @NotNull final Set<? super PsiClass> found) { final PsiManager manager = testClassFilter.getPsiManager(); final Project project = manager.getProject(); GlobalSearchScope projectScopeWithoutLibraries = GlobalSearchScope.projectScope(project); final GlobalSearchScope scope = projectScopeWithoutLibraries.intersectWith(testClassFilter.getScope()); final PsiClass base = testClassFilter.getBase(); if (base != null) { ClassInheritorsSearch.search(base, scope, true, true, false).forEach(new ReadActionProcessor<>() { @Override public boolean processInReadAction(PsiClass aClass) { if (testClassFilter.isAccepted(aClass)) found.add(aClass); return true; } }); } // classes having suite() method final PsiMethod[] suiteMethods = ReadAction.compute(() -> PsiShortNamesCache.getInstance(project).getMethodsByName(JUnitUtil.SUITE_METHOD_NAME, scope)); for (final PsiMethod method : suiteMethods) { ApplicationManager.getApplication().runReadAction(() -> { final PsiClass containingClass = method.getContainingClass(); if (containingClass == null) return; if (containingClass instanceof PsiAnonymousClass) return; if (containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) return; if (containingClass.getContainingClass() != null && !containingClass.hasModifierProperty(PsiModifier.STATIC)) return; if (JUnitUtil.isSuiteMethod(method) && testClassFilter.isAccepted(containingClass)) { found.add(containingClass); } }); } Set<PsiClass> processed = new HashSet<>(); boolean hasJunit4 = addAnnotatedMethodsAnSubclasses(scope, testClassFilter, module, found, processed, JUnitUtil.TEST_ANNOTATION, manager.getProject()); hasJunit4 |= addAnnotatedMethodsAnSubclasses(scope, testClassFilter, module, found, processed, JUnitUtil.RUN_WITH, manager.getProject()); return hasJunit4; }