【发布时间】:2018-10-22 17:14:50
【问题描述】:
也许这很简单,但我在网上找不到任何示例:
我想使用 JUnit 5 来运行一个作为 Groovy 类实现的单元测试。我当前的设置似乎启动了 JUnit 5,但未能检测到测试用例。 IntelliJ 识别测试,但无法运行它。如果我添加一个 Java 单元测试,它会正确启动。
这是我现在拥有的:
项目结构
src
main
groovy
# production code
test
groovy
UnitTest.groovy
build.gradle
...
build.gradle
plugins {
id 'groovy'
}
dependencies {
compile localGroovy()
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.1'
}
test {
useJUnitPlatform()
}
UnitTest.groovy
import org.junit.jupiter.api.Test
class UnitTest {
@Test
def shouldDoStuff() {
throw new RuntimeException()
}
}
我正在使用 Gradle 4.10。
有什么想法吗?
【问题讨论】: