【发布时间】:2019-12-26 08:43:20
【问题描述】:
我们不能在一个 gardle 项目 中同时运行使用 Junit 5 和 Spock 框架 编写的测试用例吗?
我们尝试将https://www.baeldung.com/junit-5-gradle 中给出的依赖项添加到我们的 gradle 文件中。 Gradle 版本是 4.10.3 和 Junit 5。下面是我的 build.gradle 文件
apply plugin: 'groovy'
apply plugin: 'java'
repositories {
mavenCentral()
maven {
url "http://repo.fusesource.com/nexus/content/groups/public/"
}
maven {
url "https://repository.jboss.org/nexus/content/groups/public"
}
jcenter()
}
dependencies {
compile group: 'com.google.inject', name: 'guice', version: '4.2.2'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
testCompile(
'org.codehaus.groovy:groovy-all:2.4.8',
'org.spockframework:spock-core:1.0-groovy-2.4',
'org.jmockit:jmockit:1.8',
'junit:junit:4.12'
)
testRuntime(
'cglib:cglib:2.2.2',
'com.athaydes:spock-reports:1.2.7'
)
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testCompileOnly 'junit:junit:4.12'
}
test {
useJUnitPlatform()
testLogging { showStandardStreams = true }
}
我创建了两个测试用例,一个使用 spock 框架,另一个使用 junit 5。但是当我执行 gradlew -test 时,它只运行用 Junit 5 编写的测试用例。下面是构建路径。
【问题讨论】:
标签: unit-testing gradle build.gradle spock junit5