I’m writing convention plugins and I have questions with regards to how test dependencies transfer to dependent plugins.
My base
plugin defines
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:$junitPlatformVersion")
}
My server
plugin defines
plugins {
id("com.my.base") // the above plugin
id("war")
id("jvm-test-suite")
}
testing {
suites {
configureEach {
useJUnitJupiter()
dependencies {
// automatic for 'test', but not for the others
implementation(project())
// these are needed despite being declared as dependencies in the parent plugin
implementation("org.junit.jupiter:junit-jupiter:$junitVersion")
runtimeOnly("org.junit.platform:junit-platform-launcher:$junitPlatformVersion")
}
}
test {
dependencies {
implementation("org.jboss.weld:weld-junit5:$weldJunitVersion")
}
}
integrationTest(JvmTestSuite) {
dependencies {
implementation("org.jboss.arquillian.junit5:arquillian-junit5-container:$arquillianVersion")
}
}
}
}
As commented, the test dependencies are not “inherited” by the test suits, at least that’s what I found out. My questions:
- Is this correct behavior? I need to choose either test suites or test dependencies?
- I want all the tests in projects that apply the base plugin to have the jupiter dependencies. How can I specify them once in that plugin and have the applying projects “inherit” them?
- If in the base plugin I define test suits, and then in applying projects (server) I also define test suits, what are the rules for “inheritance” and overriding? Are test suites overriden separately (test overrides test, intergrationTest overrides integrationTest)? Combined? Is the whole
testing
block overriden?
I didn’t see this covered in The JVM Test Suite Plugin, but maybe I don’t understand a more basic concept that should be obvious.