From 47935c19e64e7494eb0a65a48a27ec33adfc6843 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 8 Nov 2018 17:30:18 +0100 Subject: [PATCH] Show line markers for JUnit test methods in abstract class #KT-27977 Fixed --- .../idea/platform/JvmIdePlatformKindTooling.kt | 2 +- .../runMarkers/jUnitTestClassWithSubclasses.kt | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/platform/JvmIdePlatformKindTooling.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/platform/JvmIdePlatformKindTooling.kt index ef1b71d4944..af5b332a74f 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/platform/JvmIdePlatformKindTooling.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/platform/JvmIdePlatformKindTooling.kt @@ -68,7 +68,7 @@ class JvmIdePlatformKindTooling : IdePlatformKindTooling() { val lightMethod = declaration.toLightMethods().firstOrNull() ?: return null val lightClass = lightMethod.containingClass as? KtLightClass ?: return null val framework = TestFrameworks.detectFramework(lightClass) ?: return null - if (!framework.isTestMethod(lightMethod)) return null + if (!framework.isTestMethod(lightMethod, /*checkAbstract = */ false)) return null "java:test://${lightClass.qualifiedName}.${lightMethod.name}" to framework } diff --git a/idea/testData/codeInsight/lineMarker/runMarkers/jUnitTestClassWithSubclasses.kt b/idea/testData/codeInsight/lineMarker/runMarkers/jUnitTestClassWithSubclasses.kt index 5245b84fe1c..f5720a114ef 100644 --- a/idea/testData/codeInsight/lineMarker/runMarkers/jUnitTestClassWithSubclasses.kt +++ b/idea/testData/codeInsight/lineMarker/runMarkers/jUnitTestClassWithSubclasses.kt @@ -5,12 +5,14 @@ import junit.framework.TestCase import org.junit.Test abstract class KBase : TestCase() { + // NOTE: this differs from Java tooling behaviour, see KT-27977 @Test - fun testFoo() { + fun testFoo() { } } + class KTest : KBase() { @Test fun testBar() { @@ -23,4 +25,13 @@ class KTest2 : KBase() { fun testBaz() { } -} \ No newline at end of file +} + +abstract class AbstractClassWithoutInheritors : TestCase() { + // NOTE: showing line markers for abstract method, which has no inheritors is not ideal, because those methods cannot actually be run + // Sadly, run configurations can actually be created for them (same in Java), so this behaviour is consistent with context menu + @Test + fun testFoo() { + + } +}