IDEA-202179 fixed wrong test runner for abstract method tests

This commit is contained in:
Sergei Vorobyov
2019-02-11 19:31:54 +03:00
committed by Sergei Vorobyov
parent a7c4f869f3
commit d952220a2d
3 changed files with 13 additions and 1 deletions
@@ -38,6 +38,10 @@ public abstract class TestFrameworks {
public abstract boolean isTestMethod(PsiMethod method);
public boolean isTestMethod(PsiMethod method, boolean checkAbstract) {
return isTestMethod(method);
}
public boolean isTestOrConfig(PsiClass psiClass) {
return isTestClass(psiClass) || hasConfigMethods(psiClass);
}
@@ -94,4 +94,12 @@ public class TestFrameworksImpl extends TestFrameworks {
}
return false;
}
@Override
public boolean isTestMethod(PsiMethod method, boolean checkAbstract) {
for (TestFramework framework : TestFramework.EXTENSION_NAME.getExtensionList()) {
if (framework.isTestMethod(method, checkAbstract)) return true;
}
return false;
}
}
@@ -62,7 +62,7 @@ public class GradleRunnerUtil {
public static Location<PsiMethod> getTestMethod(final Location<?> location) {
for (Iterator<Location<PsiMethod>> iterator = location.getAncestors(PsiMethod.class, false); iterator.hasNext(); ) {
final Location<PsiMethod> methodLocation = iterator.next();
if (TestFrameworks.getInstance().isTestMethod(methodLocation.getPsiElement())) return methodLocation;
if (TestFrameworks.getInstance().isTestMethod(methodLocation.getPsiElement(), false)) return methodLocation;
}
return null;
}