Kotlin/Multiplatform 如何在控制台上查看 stdout/stderr 测试?
Kotlin/Multiplatform how to see stdout/stderr of tests on console?
我尝试为类型为 Test
的所有任务设置如下:
tasks.withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
但该设置仅适用于JVM,而不适用于Kolin/Multiplatform上的所有目标。
如何direct/enable将标准输出和标准错误流输出到控制台?
控制台中只打印异常名称(甚至不打印异常消息):
> Task :keyboard:linuxX64Test FAILED
com.github.animeshz.keyboard.NativeKeyboardHandlerTest.Caps lock key should be toggled when KeyDown event is triggered FAILED
kotlin.IllegalStateException
com.github.animeshz.keyboard.NativeKeyboardHandlerTest.Test send and receive event FAILED
kotlin.IllegalStateException
我现在不知道如何调试它,当我在多个目标(在 VM 上)上测试库时,我没有(想要安装)Intellij。
您需要为每个测试任务类型定义 testLogging
,因为您目前只为 JVM 定义它,类似的东西应该在您的 build.gradle.kts
:
中工作
tasks {
val jvmTest by getting(Test::class) {
testLogging {
events("PASSED", "FAILED", "SKIPPED")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
val linuxTest by getting(KotlinNativeTest::class) {
testLogging {
events("PASSED", "FAILED", "SKIPPED")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
val jsNodeTest by getting(KotlinJsTest::class) {
testLogging {
events("PASSED", "FAILED", "SKIPPED")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
}
我尝试为类型为 Test
的所有任务设置如下:
tasks.withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
但该设置仅适用于JVM,而不适用于Kolin/Multiplatform上的所有目标。
如何direct/enable将标准输出和标准错误流输出到控制台?
控制台中只打印异常名称(甚至不打印异常消息):
> Task :keyboard:linuxX64Test FAILED
com.github.animeshz.keyboard.NativeKeyboardHandlerTest.Caps lock key should be toggled when KeyDown event is triggered FAILED
kotlin.IllegalStateException
com.github.animeshz.keyboard.NativeKeyboardHandlerTest.Test send and receive event FAILED
kotlin.IllegalStateException
我现在不知道如何调试它,当我在多个目标(在 VM 上)上测试库时,我没有(想要安装)Intellij。
您需要为每个测试任务类型定义 testLogging
,因为您目前只为 JVM 定义它,类似的东西应该在您的 build.gradle.kts
:
tasks {
val jvmTest by getting(Test::class) {
testLogging {
events("PASSED", "FAILED", "SKIPPED")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
val linuxTest by getting(KotlinNativeTest::class) {
testLogging {
events("PASSED", "FAILED", "SKIPPED")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
val jsNodeTest by getting(KotlinJsTest::class) {
testLogging {
events("PASSED", "FAILED", "SKIPPED")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showStackTraces = true
}
}
}