gradle integrationTest and testFixtures

964 views Asked by At

I'm using gradle 7.4.2 so I decided to split the tests to proper unit-test and integration-tests. I moved one class from src/test/java/com/example to src/integrationTest/java/com/example, and started to add the missing dependencies.

The problem is that I couldn't find how to use the testFixtures of :project-with-fixture . Is there a way to do that in integrationTest?

I had the following dependencies:

testImplementation project(':other-project')
testImplementation project(':project-with-fixture')
testImplementation testFixtures(project(':project-with-fixture'))
testImplementation project(':common')
testImplementation "com.google.guava:guava:${com_google_guava_version}"

And here's the new part of the build.gradle:

testing {
    suites {
        integrationTest(JvmTestSuite) {
            dependencies {
                implementation project
                implementation project(':other-project')
                implementation project(':project-with-fixture')
//                testImplementation testFixtures(project(':project-with-fixture'))
                implementation project(':common')
                implementation "com.google.guava:guava:${com_google_guava_version}"
            }

            targets {
                all {
                    testTask.configure {
                        shouldRunAfter(test)
                    }
                }
            }
        }
    }
}
tasks.named('check') {
    dependsOn testing.suites.integrationTest
}
1

There are 1 answers

0
Joern On

When using the current Gradle version 7.5.1 you can do this:

testing {
  suites {
    integrationTest(JvmTestSuite) {
      dependencies {
        implementation(project.dependencies.testFixtures(project(':project-with-fixture')))
        ...