我有 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"
}
}
最佳答案
您需要删除 check.dependsOn integrationTest
关于unit-testing - 为什么在我运行单元测试时我的集成测试也在运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35216287/