gradlebuild.gradlegradle-kotlin-dsl

How to set testLogging events in Kotlin gradle?


What is the Kotlin version of this code snippet from Groovy Gradle?

test {
    testLogging {
        events "passed", "skipped", "failed"
    }
}

I tried setting the testLogging events inside tasks.test, but it gives a compile-time error.

tasks.test {
    useJUnitPlatform()
    testLogging.events = listOf("PASSED", "FAILED", "SKIPPED")
}

Solution

  • I also found another alternative for Murat's solution.

    tasks.test {
        useJUnitPlatform()
        testLogging.events(TestLogEvent.PASSED, TestLogEvent.FAILED, TestLogEvent.SKIPPED)
    }