From 92db15dcb3209b8ef07ef7f33627767f1ee70f04 Mon Sep 17 00:00:00 2001 From: Aleksey Dobrynin Date: Fri, 22 Aug 2025 13:17:45 +0200 Subject: [PATCH] [junit5 inspection] add tests for malformed parameterized class method source IJ-CR-166493 GitOrigin-RevId: 541dacb7a76e0af153c253f4a70475c070d311a9 --- ...aJUnitMalformedDeclarationInspectionTest.kt | 17 +++++++++++++++++ ...nJUnitMalformedDeclarationInspectionTest.kt | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) 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 ee35549e23fe..f8e6cb2ffab9 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 @@ -650,6 +650,23 @@ class JavaJUnitMalformedDeclarationInspectionTest { """.trimIndent()) } + fun `test malformed parameterized class method source should not be static highlighting`() { + myFixture.testHighlighting(JvmLanguage.JAVA, """ + @org.junit.jupiter.params.ParameterizedClass + @org.junit.jupiter.params.provider.MethodSource("a") + @org.junit.jupiter.api.TestInstance(org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS) + class TestMethodSource { + @org.junit.jupiter.params.Parameter + String param; + + @org.junit.jupiter.api.Test + void test() { } + + String[] a() { return new String[] {"a", "b"}; } + } + """.trimIndent()) + } + fun `test malformed parameterized class method source should have no parameters highlighting`() { myFixture.testHighlighting(JvmLanguage.JAVA, """ @org.junit.jupiter.params.ParameterizedClass diff --git a/plugins/junit/kotlin-tests-shared/test/com/intellij/execution/junit/kotlin/codeInspection/KotlinJUnitMalformedDeclarationInspectionTest.kt b/plugins/junit/kotlin-tests-shared/test/com/intellij/execution/junit/kotlin/codeInspection/KotlinJUnitMalformedDeclarationInspectionTest.kt index 7f8faa06913d..80fb4d11a338 100644 --- a/plugins/junit/kotlin-tests-shared/test/com/intellij/execution/junit/kotlin/codeInspection/KotlinJUnitMalformedDeclarationInspectionTest.kt +++ b/plugins/junit/kotlin-tests-shared/test/com/intellij/execution/junit/kotlin/codeInspection/KotlinJUnitMalformedDeclarationInspectionTest.kt @@ -543,6 +543,24 @@ abstract class KotlinJUnitMalformedDeclarationInspectionTestLatest : KotlinJUnit """.trimIndent()) } + fun `test malformed parameterized class method source should not be static`() { + myFixture.testHighlighting( + JvmLanguage.KOTLIN, """ + @org.junit.jupiter.params.ParameterizedClass + @org.junit.jupiter.params.provider.MethodSource("a") + @org.junit.jupiter.api.TestInstance(org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS) + class TestMethodSource { + @org.junit.jupiter.params.Parameter + lateinit var param: String + + @org.junit.jupiter.api.Test + fun test() { } + + fun a(): Array { return arrayOf("a", "b") } + } + """.trimIndent()) + } + /* Malformed parameterized */ fun `test malformed parameterized @ValueSourcesTest no highlighting`() { myFixture.testHighlighting(JvmLanguage.KOTLIN, """