Coverage Summary for Class: LoggerNames_jvmAndAndroidKt (com.javiersc.mokoki.test.internal)
Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
LoggerNames_jvmAndAndroidKt |
100%
(1/1)
|
100%
(3/3)
|
75%
(3/4)
|
66.7%
(6/9)
|
78.8%
(41/52)
|
package com.javiersc.mokoki.test.internal
public actual val String?.lineNumberForTest: Int
get() = (stackTraceForTests?.lineNumber ?: +2) - 1
private val stackTraceForTests: StackTraceElement?
get() =
try {
val trace = Thread.currentThread().stackTrace
val index = trace.indexOfLast { it.isTestClass }
trace[index]
} catch (throwable: Throwable) {
println("Mokoki has not been able to get the StackTrace")
null
}
private val StackTraceElement.isTestClass: Boolean
get() = Regex("""^(com.javiersc.mokoki).*(Test)$""").matches(className)