I am trying to configure Gradle with Kotlin DSL
for my project. It consists of two modules. Module A is a simple Java 11
application. Module B cotains the acceptance tests written in Kotlin
using Spek
.
I would like to configure gradle so that gradle test
does not run the acceptance tests and these tests are run only with task gradle acceptanceTest
. I tried configuration below with other variations of filters, includes and excludes but with no luck. What am I missing?
tasks.withType<Test> {
println("always printed: configuration phase test")
useJUnitPlatform()
filter {
exclude("acceptance.*")
}
doLast {
println("only printed if executed: execution phase test")
}
}
val acceptanceTest: Task by tasks.creating(Test::class) {
println("always printed: configuration phase ac")
useJUnitPlatform {
includeEngines("spek2")
}
filter {
include("acceptance.*")
}
doLast {
println("only printed if executed: execution phase ac")
}
}
Filter was unnecessary. I just had the acceptanceTest
task in the wrong place... After moving to the acceptance
module it works as expected.