Gradle 4.6 + Junit 5:`-Dtest.single` 不起作用?

Gradle 4.6 + Junit 5: `-Dtest.single` doesn't work?

使用 Gradle 4.6,我制作了一个超级简单的测试项目来测试 JUnit 5 兼容性。 -Dtest.single 好像不行。我已经搜索了文档,我想 运行 一个单一的测试 class and/or 一个单一的测试方法。在这里,我预计

 gradle clean -Dtest.single=junittest.SampleTests test

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> Could not find matching test for pattern: junittest.SampleTests

我有一个故意失败的测试用例,名为 failingTest():

gradle clean test

> Task :test FAILED

junittest.SampleTests > failingTest() FAILED
    org.opentest4j.AssertionFailedError at SampleTests.java:16

我的build.gradle:

apply plugin: 'java'

sourceCompatibility = 8

repositories {
  mavenCentral()
  maven { url "http://packages.confluent.io/maven/" }
}

test {
  useJUnitPlatform()
}

tasks.withType(JavaCompile) {
  options.compilerArgs << "-Xlint:unchecked"
}

dependencies {
  testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
  testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
}

根据 documentationtest.single 选项基于文件名模式,即当您将 . 替换为 / 时,它有效:

./gradlew clean test -Dtest.single=junittest/SampleTests

但是,在大多数情况下使用 --tests 选项更容易:

./gradlew clean test --tests junittest.SampleTests