gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 03:38:31 24 4
gpt4 key购买 nike

使用Gradle 4.6,我制作了一个 super 简单的测试项目来测试JUnit 5的兼容性。似乎-Dtest.single不起作用。我已经搜索了文档,我想运行一个测试类和/或一个测试方法。我在这里

 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

关于gradle - Gradle 4.6 + Junit 5: `-Dtest.single`不起作用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49540494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com