简体   繁体   English

gradle集成测试和测试夹具

[英]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.

相关问题 gradle jacoco与integrationTest和排除 - gradle jacoco with integrationTest and exclusions Gradle + SpringBoot: :integrationTest 未在构建任务中执行 - Gradle + SpringBoot: :integrationTest not executed in build task Gradle IntegrationTest目标失败,退出代码为137 - Gradle integrationTest target fails with exit code 137 使用 Docker 运行 Gradle 集成测试任务时如何修复“:integrationTest NO-SOURCE” - How to fix ':integrationTest NO-SOURCE' when running Gradle integrationTest Task with Docker 如何将 Gradle testImplementation testFixtures('com.bla:bla-bla:master_d171111') 转换为 Kotlin Gradle? - How to convert Gradle testImplementation testFixtures('com.bla:bla-bla:master_d171111') to Kotlin Gradle? 如何确保我的Gradle xjc生成总是发生在IntegrationTest目标上? - How can I ensure my Gradle xjc generation always happens for integrationTest targets? 使用 Gradle jvm-test-suite,integrationTest 套件无法访问 kotlin 内部 API - With Gradle jvm-test-suite, the integrationTest suite can not access kotlin internal Apis 在 intellij 中创建 IntegrationTest 文件夹作为模块 - Creating IntegrationTest folder as module in intellij 如何在Android中使用Groovy制作IntegrationTest源集? - How can I make an integrationTest source set with groovy in android? 自定义文件夹中的集成测试:任务“:integrationTest”执行失败。 没有找到给定的测试包括 - Integration test in custom folder: Execution failed for task ':integrationTest'. No tests found for given includes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM