I’m trying to migrate a Groovy Gradle build DSL based project. This project uses the testFixtures support for Java.
As Kotlin doesn’t seem to have support for testFixtures yet I have added the org.unbroken-dome.test-sets plugin that is adding the required custom source sets. I also had used this plugin in my Groovy based build script.
As Kotlin doesn’t seem to have support for testFixtures yet I have added the org.unbroken-dome.test-sets plugin that is adding the required custom source sets.
Why do you think so?
The Kotlin DSL supports exactly the same things as the Groovy DSL.
They are just different front-end languages, but both are feature-complete and equally supported.
Also, if you want to have different kinds of tests which I guess from the name “componentTest”, I’d suggest you have a look at the built-in JVM Testsuites plugin, which allows you to easily declare multiple “test sets”.
Updated my Kotlin DSL based build script with your suggestions. This is a really neat solution. Thanks !
plugins {
id ("jvm-test-suite")
id ("java-test-fixtures")
id("org.springframework.boot") version "2.7.2"
id("io.spring.dependency-management") version "1.0.12.RELEASE"
kotlin("jvm") version "1.6.21"
kotlin("plugin.spring") version "1.6.21"
kotlin("plugin.jpa") version "1.6.21"
kotlin("plugin.allopen") version "1.6.21" // see https://kotlinlang.org/docs/all-open-plugin.html
}
// omitted code...
testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
dependencies {
implementation("org.springframework.boot:spring-boot-starter-test")
}
}
val componentTest by registering(JvmTestSuite::class) {
dependencies {
implementation(project)
implementation(project.dependencies.testFixtures(project))
implementation("org.springframework.boot:spring-boot-starter-test")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
}
targets {
all {
testTask.configure {
shouldRunAfter(test)
}
}
}
}
}
}
tasks.named("check") {
dependsOn(testing.suites.named("componentTest"))
}