can be static: do not check for testng tests/configurations ( IDEADEV-41672 )

This commit is contained in:
anna
2009-11-30 18:31:45 +03:00
parent 222ce59abe
commit 1eace0d882
7 changed files with 102 additions and 18 deletions
@@ -32,6 +32,10 @@ import gnu.trove.THashSet;
import junit.runner.BaseTestRunner;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runners.Parameterized;
import java.util.*;
@@ -193,6 +197,26 @@ public class JUnitUtil {
return JavaPsiFacade.getInstance(project).findClass(TESTCASE_CLASS, scope);
}
public static boolean isTestMethodOrConfig(PsiMethod psiMethod) {
if (getTestMethod(psiMethod) != null) return true;
final String name = psiMethod.getName();
if (psiMethod.hasModifierProperty(PsiModifier.PUBLIC) && !psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
if ("suite".equals(name) || "setUp".equals(name) || "tearDown".equals(name)) {
return true;
}
if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) {
if (AnnotationUtil.isAnnotated(psiMethod, Arrays.asList(BeforeClass.class.getName(), AfterClass.class.getName(),
Parameterized.Parameters.class.getName().replace('$', '.')))) {
return true;
}
}
else {
if (AnnotationUtil.isAnnotated(psiMethod, Arrays.asList(Before.class.getName(), After.class.getName()))) return true;
}
}
return false;
}
public static class TestMethodFilter implements Condition<PsiMethod> {
private final PsiClass myClass;