junit: treat test methods in abstract test cases as tests (IDEA-174710)

This commit is contained in:
Anna Kozlova
2017-06-20 14:54:16 +03:00
parent f3b1efc3f2
commit 44170f84d1
5 changed files with 15 additions and 7 deletions
@@ -172,10 +172,6 @@ public abstract class JavaTestFramework implements TestFramework {
return isTestMethod(element, true);
}
public boolean isTestMethod(PsiElement element, boolean checkAbstract) {
return isTestMethod(element);
}
public boolean isMyConfigurationType(ConfigurationType type) {
return false;
}
@@ -73,6 +73,10 @@ public interface TestFramework {
* should be checked for abstract method error
*/
boolean isTestMethod(PsiElement element);
default boolean isTestMethod(PsiElement element, boolean checkAbstract) {
return isTestMethod(element);
}
@NotNull
Language getLanguage();
@@ -65,7 +65,7 @@ public class TestUtils {
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) return false;
final TestFramework framework = TestFrameworks.detectFramework(containingClass);
return framework != null && framework.getName().startsWith("JUnit") && framework.isTestMethod(method);
return framework != null && framework.getName().startsWith("JUnit") && framework.isTestMethod(method, false);
}
public static boolean isRunnable(PsiMethod method) {
@@ -16,4 +16,10 @@ public class <warning descr="JUnit test case 'TestCaseWithNoTestMethods' has no
public void tearDown() throws Exception {
super.tearDown();
}
}
}
abstract class AbstractTest extends junit.framework.TestCase {
public void testInAbstract() {}
}
class MyImplTest extends AbstractTest {}
@@ -29,7 +29,9 @@ public class TestCaseWithNoTestMethodsInspectionTest extends LightInspectionTest
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new TestCaseWithNoTestMethodsInspection();
TestCaseWithNoTestMethodsInspection inspection = new TestCaseWithNoTestMethodsInspection();
inspection.ignoreSupers = true;
return inspection;
}
@Override