I'm using java-test-fixtures
in combination with jvm-test-suite
. I'd like my testFixtures
to be available to both unit tests and my integrationTest
suite.
java-test-fixtures
adds testFixtures
as a dependency to the default unit test suite, along with compile-time and runtime transitive dependencies. What's the right way to add this to integrationTest
too?
The following works, but it seems a bit repetitive:
plugins {
id 'java'
id 'application'
id 'java-test-fixtures'
id 'jvm-test-suite'
}
testing {
suites {
integrationTest(JvmTestSuite) {
dependencies {
implementation sourceSets.testFixtures.output
}
configurations {
integrationTestCompileClasspath.extendsFrom testFixturesApi
integrationTestRuntimeClasspath.extendsFrom testFixturesRuntimeClasspath
}
}
}
}
I can also use testFixtures(project)
, but only if I declare the dependency in a top-level dependency block, with the top-level dependency block appearing after the test suite has been declared:
testing {
suites {
integrationTest(JvmTestSuite) {}
}
}
dependencies {
integrationTestImplementation testFixtures(project)
}
This works, with all the transitive dependencies set up correctly.
Curiously, I can't use testFixtures(project)
inside the test suite declaration - the following:
testing {
suites {
integrationTest(JvmTestSuite) {
dependencies {
implementation testFixtures(project)
}
}
}
}
...fails to evaluate.
Is there a preferred way to have a test suite depend upon testFixtures
?
I hate to answer my own question! The cleanest solution right now appears to be to fully-qualify the
testFixtures
function inside the test'sdependencies
block: