我使用的是Gradle 7.4.2,所以我决定将测试分成适当的单元测试和集成测试。我将一个类从src/test/java/com/example移动到src/integrationTest/java/com/example,并开始添加缺失的依赖。
问题在于我找不到如何使用:project-with-fixture的testFixtures。在integrationTest中有没有办法做到这一点?
我有以下依赖项:
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}"
以下是新的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
}