Trying to follow this to configure unit tests so I...
# kotlin-dsl
k
Trying to follow this to configure unit tests so I can see which one it was executing before it throws "Process 'Gradle Test Executor 38' finished with non-zero exit value 134": https://docs.gradle.org/8.12.1/userguide/java_testing.html#sec:java_testing_basics
Copy code
tasks.named<Test>("test") {
    useJUnit()

    beforeTest {
        logger.lifecycle("Running unit test: $it")
    }
}
It wants a closure instead for the beforeTest bit:
Argument type mismatch: actual type is 'Function0<Unit>', but '(Closure<Any!>..Closure<*>?)' was expected.
How do you specify a closure in kotlin-dsl?
k
TIL:
KotlinClosure2
in Kotlin DSL to produce the Groovy closure thanks!
also TIL closureOf:
Copy code
beforeTest(closureOf<TestDescriptor> { logger.lifecycle("Test: $this") })
a
np! There's more info on this page about the utils Gradle provides to help using Groovy from Kotlin. But they're rarely needed these days. https://docs.gradle.org/8.13/userguide/kotlin_dsl.html#groovy_closures_from_kotlin
thank you 1
v
And you should be able to just run with
--info
to see what test is executed afair, or run through an IDE that displays currently executing tests
k
The test executor failure is sporadic but good to know I can just modify the gradle command in CI... Though it would print a lot more info probably.
v
... yes, but on CI I personally would always at least use
--info
🙂
👍 1