IDEA-203748 @MethodSource recognized in super classes and interfaces

GitOrigin-RevId: f5d55b876080a699dcd54cec71a04dae7af84ba8
This commit is contained in:
Olga.Klisho
2020-08-07 23:56:02 +00:00
committed by intellij-monorepo-bot
parent 60b36b13bc
commit ff498b46ba
3 changed files with 34 additions and 5 deletions
@@ -166,10 +166,10 @@ class JUnit5MalformedParameterizedInspection : AbstractBaseJavaLocalInspectionTo
if (annotationMemberValue == null) {
if (methodSource.findAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME) == null) return
val providerName = method.name
val methods = containingClass.findMethodsBySignature(
JavaPsiFacade.getElementFactory(method.project).createMethodFromText("void $providerName()", method), false)
if (methods.isNotEmpty()) {
doCheckSourceProvider(methods[0], containingClass, methodSource, method)
val foundMethod = containingClass.findMethodBySignature(
JavaPsiFacade.getElementFactory(method.project).createMethodFromText("void $providerName()", method), true)
if (foundMethod != null) {
doCheckSourceProvider(foundMethod, containingClass, methodSource, method)
}
else {
highlightAbsentSourceProvider(containingClass, methodSource, providerName, method)
@@ -6,7 +6,7 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
public class JUnit5TestFrameworkSetupUtil {
public static JavaCodeInsightTestFixture setupJUnit5Library(JavaCodeInsightTestFixture fixture) {
fixture.addClass( "package org.junit.jupiter.params.provider;\n" +
"public @interface MethodSource {String[] value();}");
"public @interface MethodSource {String[] value() default \"\";}");
fixture.addClass( "package org.junit.jupiter.params;\n" +
"@org.junit.platform.commons.annotation.Testable\n" +
"public @interface ParameterizedTest {}");
@@ -210,4 +210,33 @@ abstract class FooThree {
void test(String value) {}
abstract List<String> method1();
}
class SomeTest extends Base {
@ParameterizedTest
@MethodSource
void testSomething(String content) {}
}
class SomeTestTwo implements Inter {
@ParameterizedTest
@MethodSource
void testSomething(String content) {}
}
interface Inter extends Inter2{ }
interface Inter2 {
static Stream<String> testSomething() {
return Stream.of("a", "aa");
}
}
class Base {
static Stream<String> testSomething() {
return Stream.of("a", "aa");
}
}