mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[junit5]: IDEA-378955 reject abstract methods as tests for standard annotations
NOTE: not for junit4 GitOrigin-RevId: 9e6aa1ecbb414e79eb80178127100f3f83ae39b4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dcf14b48fb
commit
f0be58fbd9
@@ -376,6 +376,7 @@ public final class JUnitUtil {
|
||||
ProgressManager.checkCanceled();
|
||||
if (!method.hasModifierProperty(PsiModifier.PRIVATE) &&
|
||||
!method.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
!method.hasModifierProperty(PsiModifier.ABSTRACT) &&
|
||||
MetaAnnotationUtil.isMetaAnnotated(method, CUSTOM_TESTABLE_ANNOTATION_LIST)) {
|
||||
hasAnnotation = true;
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.junit5;
|
||||
|
||||
import com.intellij.codeInsight.TestFrameworks;
|
||||
@@ -54,6 +54,29 @@ public class JUnit5AcceptanceTest extends JUnit5CodeInsightTest {
|
||||
assertTrue(JUnitUtil.isTestMethod(MethodLocation.elementInClass(innerClass.getMethods()[0], innerClass)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectAbstractMethods() {
|
||||
PsiClass aClass = myFixture.addClass("""
|
||||
import org.junit.jupiter.api.*;
|
||||
/** @noinspection ALL*/
|
||||
abstract class MyTest {
|
||||
@Test abstract void method();
|
||||
}
|
||||
""");
|
||||
assertFalse(TestFrameworks.getInstance().isTestClass(aClass));
|
||||
assertFalse(TestFrameworks.getInstance().isTestMethod(aClass.getMethods()[0]));
|
||||
|
||||
PsiClass iClass = myFixture.addClass("""
|
||||
import org.junit.jupiter.api.*;
|
||||
/** @noinspection ALL*/
|
||||
abstract class InheritedTest extends MyTest {
|
||||
@Override void method();
|
||||
}
|
||||
""");
|
||||
assertFalse(TestFrameworks.getInstance().isTestClass(iClass));
|
||||
assertFalse(TestFrameworks.getInstance().isTestMethod(iClass.getMethods()[0]));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectStaticMethods() {
|
||||
PsiClass aClass =
|
||||
|
||||
Reference in New Issue
Block a user