3

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
}
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Gavriel
  • 18,880
  • 12
  • 68
  • 105

1 Answers1

0

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')))
        ...
Joern
  • 1,926
  • 1
  • 13
  • 18