kotest-intellij-plugin icon indicating copy to clipboard operation
kotest-intellij-plugin copied to clipboard

Cannot navigate to, or run, included tests

Open Mahoney opened this issue 5 years ago • 4 comments

Not surprisingly, it's going to be hard to work out, and this is partly a note to self to try and solve, but:

Given these reusable tests:

interface Dependency
class StubbedDependency : Dependency
class RealDependency : Dependency

fun someSpecs(
  dependency: Dependency
) = stringSpec {
  "test 1" { TODO() }
  "test 2" { TODO() }
}

class UsingStubbedDependencySpecs : StringSpec({
  include(someSpecs(StubbedDependency()))
})

class UsingRealDependencySpecs : StringSpec({
  include(someSpecs(RealDependency()))
})

I cannot:

  1. Run someSpecs from the declaration fun someSpecs - there's no gutter icon
  2. Run test 2 in isolation - there's no gutter icon
  3. Navigate to the individual test declarations from the Test Results tree in the Run panel

In the equivalent JUnit scenario where you use an abstract super class, all three work; 1 & 2 offer you the options to run against either UsingStubbedDependencySpecs, or UsingRealDependencySpecs, or both, and 3 takes you to the test declaration in SomeSpecs. In:

import org.junit.jupiter.api.Test

abstract class SomeSpecs(
  dependency: Dependency
) {

  @Test
  fun `test 1`() { TODO() }

  @Test
  fun `test 2`() { TODO() }
}

class UsingStubbedDependencySpecs : SomeSpecs(StubbedDependency())

class UsingRealDependencySpecs : SomeSpecs(RealDependency())

I guess the plugin would need to read the call hierarchy to find all the classes extending *Spec where include is passed the result of function that ultimately calls stringSpec...

Mahoney avatar Oct 17 '20 13:10 Mahoney