【发布时间】:2016-02-05 04:27:38
【问题描述】:
我有基于 spring、spring MVC 和 gradle 的 Web 应用程序。我已经在应用程序中配置了单元测试和集成测试。
当我运行 gradle 测试时,它也会运行我的集成测试。我不知道为什么。
我已将集成测试保存在单独的源文件夹中。
我的单元测试在 src/test/java 中,集成测试在 src/integTest/java 中。
下面是我的 build.gradle
check.dependsOn integrationTest
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integTest/java')
}
resources.srcDir file('src/integTest/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
task integrationTest(type: Test) {
description = "Runs the integration tests."
group = "verification"
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
testLogging {
events "skipped", "failed"
}
}
【问题讨论】:
-
为什么投反对票?任何评论都将有助于改进问题,或者如果有任何遗漏。
-
我在这里没有看到任何明显的问题。如果您运行
gradle test --info,它可能会告诉您为什么它正在运行 integrationTest 任务。如果不是很明显,也许你可以尝试使用任务树插件github.com/dorongold/gradle-task-tree 看看是否有意外的任务依赖。
标签: unit-testing gradle integration-testing