Show line markers for JUnit test methods in abstract class

#KT-27977 Fixed
This commit is contained in:
Pavel V. Talanov
2018-11-08 17:30:18 +01:00
parent 9c51f521a9
commit 47935c19e6
2 changed files with 14 additions and 3 deletions
@@ -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
}
@@ -5,12 +5,14 @@ import junit.framework.TestCase
import org.junit.Test
abstract class <lineMarker descr="*"><lineMarker descr="Run Test">KBase</lineMarker></lineMarker> : TestCase() {
// NOTE: this differs from Java tooling behaviour, see KT-27977
@Test
fun testFoo() {
fun <lineMarker descr="Run Test">testFoo</lineMarker>() {
}
}
class <lineMarker descr="*">KTest</lineMarker> : KBase() {
@Test
fun <lineMarker descr="*">testBar</lineMarker>() {
@@ -23,4 +25,13 @@ class <lineMarker descr="*">KTest2</lineMarker> : KBase() {
fun <lineMarker descr="*">testBaz</lineMarker>() {
}
}
}
abstract class <lineMarker descr="*"><lineMarker descr="Run Test">AbstractClassWithoutInheritors</lineMarker></lineMarker> : 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 <lineMarker descr="Run Test">testFoo</lineMarker>() {
}
}