Is there a way to make kotest failures to always p...
# kotest
k
Is there a way to make kotest failures to always print the line number where matcher failed? For example, in a simple test like this it’s not obvious which lined failed exactly:
Copy code
fun a(): Any = 1
fun b(): Any = ""

test("foo") {
  a().shouldBeTypeOf<String>()
  b().shouldBeTypeOf<String>()
}
output:
Copy code
1 should be of type kotlin.String
Sometimes I do see kotest print full stacktrace with line number but not in this case for some reason
e
Works for me, both when run through gradle and kotest runner (intellij)
what platform are you testing on?
k
KMP, tried targeting JVM and Android
host platform? mac OS
when running from CLI using gradle task:
Copy code
....SomeTests[jvm] > foo[jvm] FAILED
    java.lang.AssertionError: 1 should be of type kotlin.String
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167)
        at ....
Is there something off in my build config setup?
e
Hard to tell from just looking at this.. I think
shouldBeTypeOf
inlines code, and perhaps when running from CLI that is not translated properly into a good stacktrace. Can you try running from intellij?
k
I originally discovered this problem in IJ (well, Android Studio) 🙂