https://kotlinlang.org logo
#kotest
Title
# kotest
k

Kirill Zhukov

03/20/2023, 7:24 PM
Is it expected for
AbstractProjectConfig
to be picked up by Kotest in a KMP project? It doesn’t seem to be working for me 🤔 https://github.com/kotest/kotest/issues/3462
e

Emil Kantis

03/20/2023, 7:54 PM
the auto-detection depends on classpath scanning, so yes - it doesn't work on other targets
k

Kirill Zhukov

03/20/2023, 9:25 PM
@Emil Kantis, do you mean it doesn’t work with non-jvm targets?
That would make sense
But I’ve seen this problem locally with
jvmTest
e

Emil Kantis

03/20/2023, 9:29 PM
Graalvm?
k

Kirill Zhukov

03/20/2023, 9:33 PM
amazon corretto
e

Emil Kantis

03/20/2023, 9:37 PM
Odd.. it should definitely work for jvm targets (as far as I can tell).. if you can produce a MRE I'd be happy to take a look
k

Kirill Zhukov

03/20/2023, 10:49 PM
Super weird, it’s working now 😑
Maybe I was missing gradle sync or something 😕
o

Oliver.O

03/21/2023, 8:51 AM
Actually, auto-detection works just fine on non-JVM targets: For K/Js and K/Native you have to add the Kotest Gradle plugin to the build. This will then activate a compiler plugin, which in turn picks up
AbstractProjectConfig
.
k

Kirill Zhukov

03/22/2023, 4:00 AM
I’ve had the plugin applied the whole time actually! I think I’m getting tripped up by
isolationMode
. I had it set
InstancePerTest
in the global project config and didn’t seem to be picked up on K/N. As it actually turns out, it doesn’t seem to be applied at all when set in the spec itself. So this test passes on JVM but fails on K/N:
Copy code
class Foo : FunSpec({
  isolationMode = InstancePerTest
  var count = 0

  test("count is 1") {
    count++
    count shouldBe 1
  }

  test("count is still 1") {
    count++
    count shouldBe 1
  }
})
7 Views