如何在kotlin gradle DSL中配置kotlin测试输出?
我已经让gradle为我生成了一个gradle应用程序(gradle init--type=kotlin应用程序) 它使用kotlin测试(org.jetbrains.kotlin:kotlin测试)作为测试框架 然而,当我调用“/gradlew build”并且一个测试失败时,我会得到缺少实际失败的测试断言的输出,例如如何在kotlin gradle DSL中配置kotlin测试输出?,kotlin,gradle-kotlin-dsl,Kotlin,Gradle Kotlin Dsl,我已经让gradle为我生成了一个gradle应用程序(gradle init--type=kotlin应用程序) 它使用kotlin测试(org.jetbrains.kotlin:kotlin测试)作为测试框架 然而,当我调用“/gradlew build”并且一个测试失败时,我会得到缺少实际失败的测试断言的输出,例如 de.eekboom.eeksv.SimplestTest > testStreaming FAILED java.lang.AssertionError at Simp
de.eekboom.eeksv.SimplestTest > testStreaming FAILED
java.lang.AssertionError at SimplestTest.kt:48
5 tests completed, 1 failed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///D:/dev/eeksv/build> /reports/tests/test/index.html
当然,我可以打开linked index.html查看测试结果,但这有点烦人
只有当我运行那个特定的测试(从IDEA内部)时,我才能得到更有用的输出,比如
expected:<3> but was:<2>
java.lang.AssertionError: expected:<3> but was:<2>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
...
at de.eekboom.eeksv.SimplestTest.testStreaming(SimplestTest.kt:48)
如何对kotlin执行同样的操作?使用
tasks.test{testLogging{events(TestLogEvent.FAILED);exceptionFormat=TestExceptionFormat.FULL}
不起作用吗?多谢了,我第一次尝试时不知怎么搞砸了。现在与您的准确样品配合使用效果很好!
testLogging {
events TestLogEvent.FAILED // Show specific test failures in output
exceptionFormat = TestExceptionFormat.FULL // Output full failure details
}