Jon Bayle
11/08/2024, 3:34 PMtesting {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter() // JUnit 5 only
}
register<JvmTestSuite>("integrationTest") {
testType = TestSuiteType.INTEGRATION_TEST
dependencies {
implementation(project())
}
// associate with main Kotlin compilation to access internal constants
kotlin.target.compilations.named(name) {
associateWith(kotlin.target.compilations["main"])
}
sources {
kotlin {
srcDirs("src/integration-test/kotlin")
// ITs depends on Factories that are in UTs (should we move these in a shared testUtils SourceSet?)
compileClasspath += sourceSets.test.get().output
runtimeClasspath += sourceSets.test.get().output
}
resources {
srcDirs("src/integration-test/resources")
}
}
}
}
}
tasks.named("check") {
dependsOn(testing.suites.named("integrationTest"))
}
This is because I have utility code used in both UTs in ITs, that are in the test sourceSet, to keep things simple.
Should I move shared utility code in a third SourceSet ?
I'd like to run the integrationTest only when invoking ./gradlew check
Thanks 🙏Thomas Broyer
11/08/2024, 3:35 PMVampire
11/08/2024, 3:49 PMjava-test-fixtures plugin, to have such utility code properly separated from the actual test code.Vampire
11/08/2024, 3:51 PMJon Bayle
11/08/2024, 3:55 PMtest and integrationTest suites will depend on.
Thanks!Vampire
11/08/2024, 4:10 PMVampire
11/08/2024, 4:10 PMJon Bayle
11/08/2024, 5:23 PMintegrationTest to run the IT,
Standard task check already runs the default test task, and my config added a dependency to task integrationTest
Now I understand why it always ran both the UT and the IT.
Thanks guys, sorry for the noise 😇