diff --git a/plugins/junit/src/com/intellij/execution/junit/TestClassFilter.java b/plugins/junit/src/com/intellij/execution/junit/TestClassFilter.java index a5991e77efb4..ec6a7e770f72 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestClassFilter.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestClassFilter.java @@ -86,9 +86,7 @@ public class TestClassFilter implements ClassFilter.ClassFilterWithScope { final PsiClass testCase = ApplicationManager.getApplication().runReadAction(new Computable() { @Override public PsiClass compute() { - if (JUnitUtil.isJUnit5(module != null ? GlobalSearchScope.moduleRuntimeScope(module, true) - : sourceScope.getLibrariesScope(), - sourceScope.getProject())) { + if (TestObject.isJUnit5(module, sourceScope, sourceScope.getProject())) { return null; } try { diff --git a/plugins/junit/src/com/intellij/execution/junit/TestObject.java b/plugins/junit/src/com/intellij/execution/junit/TestObject.java index 0352361fde03..6f5e7c6cf855 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestObject.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestObject.java @@ -159,8 +159,7 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState JUnitUtil.isJUnit5(sourceScope.getLibrariesScope(), myProject))) { + final SourceScope sourceScope = getSourceScope(); + final Module module = getConfiguration().getConfigurationModule().getModule(); + if (sourceScope != null && !ReadAction.compute(() -> isJUnit5(module, sourceScope, myProject))) { try { final TestClassFilter classFilter = getClassFilter(data); LOG.assertTrue(classFilter.getBase() != null); @@ -102,7 +103,7 @@ public class TestPackage extends TestObject { try { dumbService.setAlternativeResolveEnabled(true); final SourceScope sourceScope = data.getScope().getSourceScope(getConfiguration()); - if (sourceScope == null || !JUnitUtil.isJUnit5(sourceScope.getLibrariesScope(), project)) { //check for junit 5 + if (sourceScope == null || !isJUnit5(getConfiguration().getConfigurationModule().getModule(), sourceScope, project)) { //check for junit 5 getClassFilter(data);//check if junit 4 found } }