[英]gradle integrationTest and testFixtures
I'm using gradle 7.4.2 so I decided to split the tests to proper unit-test and integration-tests.我正在使用 gradle 7.4.2,所以我决定将测试拆分为适当的单元测试和集成测试。 I moved one class from src/test/java/com/example to src/integrationTest/java/com/example, and started to add the missing dependencies.
我将一个 class 从 src/test/java/com/example 移动到 src/integrationTest/java/com/example,并开始添加缺少的依赖项。
The problem is that I couldn't find how to use the testFixtures of:project-with-fixture.问题是我找不到如何使用 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:这是 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
}
When using the current Gradle version 7.5.1 you can do this:使用当前 Gradle 版本 7.5.1 时,您可以这样做:
testing {
suites {
integrationTest(JvmTestSuite) {
dependencies {
implementation(project.dependencies.testFixtures(project(':project-with-fixture')))
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.