I’m trying to add more targets to JvmTestSuite , my understanding was that a suite can have many targets , where each target is a Test task configured differently.
we want to have multiple Test tasks executing with the same source set but possibly different configuration and maybe different dependencies.
it works with gradle 7.3.3, but with 7.4 is get an error:
Could not configure suite: ‘integrationTest’. Another test suite: ‘integrationTest’ uses the type: ‘integration-test’ and has already been configured in project: ‘runtime-agent-test’.
i want to do something like that but i can’t understand how to do it. i tried adding different testType to each suite but didn’t help.
testing {
suites {
test {
useJUnitJupiter(testinglibs.versions.junit.jupiter.get())
dependencies {
implementation project(':test-utils')
}
sources {
java {
srcDirs = ['src/test/java']
}
resources {
//sharing the same log4j configuration for all test suites
srcDirs += [project.rootProject.file('shared/log4j-test')]
}
}
targets {
all {
testTask.configure {
systemProperty 'MyProp','default-value'
forkEvery = 1
}
}
test{
testTask.configure {
systemProperty 'MyProp','test value'
}
}
secondaryTest{
testTask.configure {
systemProperty 'MyProp','secondaryTest value'
}
}
}
}
integrationTest(JvmTestSuite) {
useJUnitJupiter(testinglibs.versions.junit.jupiter.get())
dependencies {
implementation project(':test-utils')
}
sources {
java {
srcDirs = ['src/it/java']
}
resources {
//sharing the same log4j configuration for all test suites
srcDirs += [project.rootProject.file('shared/log4j-test')]
}
}
targets {
all {
testTask.configure {
systemProperty 'MyProp','default-value'
forkEvery = 1
}
}
integrationTest{
testTask.configure {
systemProperty 'MyProp','integrationTest value'
}
}
secondaryIntegrationTest{
testTask.configure {
systemProperty 'MyProp','secondaryIntegrationTest value'
}
}
}
}
}
}