如何在Kotlin Gradle DSL中配置Kotlin测试输出?

时间:2019-09-14 13:29:52

标签: kotlin gradle-kotlin-dsl

我让gradle为我生成了gradle应用(gradle init --type = kotlin-application)。

它使用kotlin-test(org.jetbrains.kotlin:kotlin-test)作为测试框架。

但是,当我调用“ ./gradlew build”并且测试失败时,我会得到缺少实际失败的测试断言的输出,例如

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

我当然可以打开链接的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)

当我使用Java和gradle groovy DSL时,可以通过配置test任务来解决此问题:

        testLogging {
            events TestLogEvent.FAILED // Show specific test failures in output
            exceptionFormat = TestExceptionFormat.FULL // Output full failure details
        }

如何为Kotlin做同样的事情?

0 个答案:

没有答案