mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[junit5] add support for missing @Nested annotation with @ParameterizedTest IDEA-375467
GitOrigin-RevId: bda9b0049275ca94b80eb02c3f4983b542163eb4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
34591b74c7
commit
c88e6fd0d6
+28
@@ -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 <error descr="Tests in nested class will not be executed">InnerTest</error> {
|
||||
@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 {
|
||||
|
||||
+2
-1
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user