Show line markers for JUnit test methods in abstract class
#KT-27977 Fixed
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
+13
-2
@@ -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>() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user