Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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")
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In Kotlin DSL, to set the testLogging events, you can do it like this:

tasks.test {
    useJUnitPlatform()
    testLogging {
        events("passed", "skipped", "failed")
    }
}

Here, inside the testLogging block, we call the events function and specify the events you want. In your code, there’s a small mistake; instead of testLogging.events = listOf(...), you should use events(...) directly.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading