diff --git a/plugins/junit/java-tests/test/com/intellij/execution/junit/codeInspection/JavaJUnitMalformedDeclarationInspectionTest.kt b/plugins/junit/java-tests/test/com/intellij/execution/junit/codeInspection/JavaJUnitMalformedDeclarationInspectionTest.kt index 20ff16ff68f9..35e8014636a8 100644 --- a/plugins/junit/java-tests/test/com/intellij/execution/junit/codeInspection/JavaJUnitMalformedDeclarationInspectionTest.kt +++ b/plugins/junit/java-tests/test/com/intellij/execution/junit/codeInspection/JavaJUnitMalformedDeclarationInspectionTest.kt @@ -652,6 +652,19 @@ class JavaJUnitMalformedDeclarationInspectionTest { void implicitConversionClass(Book book) { } static class Book { public Book(String title) { } } + + static class StaticInnerTest { + @org.junit.jupiter.params.ParameterizedTest + @org.junit.jupiter.params.provider.ValueSource(strings = {"1","2"}) + public void test(String data) {} + } + + @org.junit.jupiter.api.Nested + class NestedInnerTest { + @org.junit.jupiter.params.ParameterizedTest + @org.junit.jupiter.params.provider.ValueSource(strings = {"1","2"}) + public void test(String data) {} + } } class MethodSource { @@ -974,6 +987,21 @@ class JavaJUnitMalformedDeclarationInspectionTest { } """.trimIndent()) } + fun `test malformed ParameterizedTest inner class should be nested highlighting`() { + myFixture.testHighlighting(JvmLanguage.JAVA, """ + class OuterTest { + @org.junit.jupiter.params.ParameterizedTest + @org.junit.jupiter.params.provider.ValueSource(strings = {"1","2"}) + public void test(String data) {} + + class InnerTest { + @org.junit.jupiter.params.ParameterizedTest + @org.junit.jupiter.params.provider.ValueSource(strings = {"1","2"}) + public void test(String data) {} + } + } + """.trimIndent()) + } fun `test malformed parameterized multiple types highlighting`() { myFixture.testHighlighting(JvmLanguage.JAVA, """ class ValueSourcesTest { diff --git a/plugins/junit/src/com/intellij/execution/junit/codeInspection/JUnitMalformedDeclarationInspection.kt b/plugins/junit/src/com/intellij/execution/junit/codeInspection/JUnitMalformedDeclarationInspection.kt index 1ffdccd3d97a..1121b0d14ae8 100644 --- a/plugins/junit/src/com/intellij/execution/junit/codeInspection/JUnitMalformedDeclarationInspection.kt +++ b/plugins/junit/src/com/intellij/execution/junit/codeInspection/JUnitMalformedDeclarationInspection.kt @@ -386,7 +386,8 @@ private class JUnitMalformedSignatureVisitor( val javaClass = aClass.javaPsi if (aClass.isInterface || aClass.javaPsi.hasModifier(JvmModifier.ABSTRACT)) return val hasNestedAnnotation = javaClass.hasAnnotation(ORG_JUNIT_JUPITER_API_NESTED) - if (!hasNestedAnnotation && !aClass.methods.any { it.javaPsi.hasAnnotation(ORG_JUNIT_JUPITER_API_TEST) }) return + if (!hasNestedAnnotation && !aClass.methods.any { it.javaPsi.hasAnnotation(ORG_JUNIT_JUPITER_API_TEST) || + it.javaPsi.hasAnnotation(ORG_JUNIT_JUPITER_PARAMS_PARAMETERIZED_TEST)}) return if (!hasNestedAnnotation && aClass.isStatic) return if (hasNestedAnnotation && !aClass.isStatic && aClass.visibility != UastVisibility.PRIVATE) return val message = JUnitBundle.message("jvm.inspections.junit.malformed.missing.nested.annotation.descriptor")