For the same reason you should not use tasks.withType(Test) { ... }
in Groovy, you shouldn’t use tasks.withType<Test>() { ... }
in Kotlin (destroying task configuration avoidance for all test tasks).
That those methods do only have a Closure
variant is surely a shortcoming you could request get fixed with a feature request.
But in the meantime, you can use KotlinClosure2
like:
tasks.withType<Test>().configureEach {
afterTest(KotlinClosure2<TestDescriptor, TestResult, Unit>({ _, result ->
if (result.resultType == TestResult.ResultType.SKIPPED) {
throw GradleException("Do not ignore test cases")
}
}))
}