Gradle 版本更新后在构建中找不到测试
Gradle tests not found on build after version update
我在 gradle 构建时遇到问题。
这是我的 build.gradle 文件:
import groovy.xml.XmlSlurper
import groovy.xml.MarkupBuilder
def property(String key) { return project.findProperty(key).toString() }
static def definedInPluginXml(String key) {
File pluginXmlFile = new File('src/main/resources/META-INF/plugin.xml')
def idea = new XmlSlurper().parse(pluginXmlFile)
return idea."$key"
}
plugins {
id 'org.jetbrains.intellij' version '1.5.3'
id 'groovy'
id 'java'
id 'org.jetbrains.changelog' version '1.2.1'
}
apply plugin: 'org.jetbrains.changelog'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = '2022.1'
plugins = ['java', 'com.intellij.java', 'org.intellij.groovy']
}
/**
* Refreshes the plugin.xml file for deployment
*/
String ideaMinVersion = property("ideaMinVersion")
String ideaMaxVersion = property("ideaMaxVersion")
String pluginVersion = property("version")
patchPluginXml {
changeNotes = changelog.get(pluginVersion).toHTML()
version = pluginVersion
sinceBuild = ideaMinVersion
untilBuild = ideaMaxVersion
}
test {
useJUnit()
filter{
includeTestsMatching "fr.nereide.*"
}
}
tasks {
runIde {
jvmArgs("-Xmx2048m")
}
}
/**
* Config for changelog Plugin
*/
changelog {
itemPrefix = "-"
keepUnreleasedSection = false
unreleasedTerm = "[Unreleased]"
groups = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"]
}
/**
* Generates the updatePlugin.xml files used for the repo.
*/
task generateUpdatePluginXml {
//...
}
/**
* Adds tests on build
*/
buildPlugin {
dependsOn 'test'
dependsOn 'generateUpdatePluginXml'
tasks.findByName('generateUpdatePluginXml').mustRunAfter 'patchPluginXml'
}
这里是版本信息:
./gradlew --version
Welcome to Gradle 7.1!
Here are the highlights of this release:
- Faster incremental Java compilation
- Easier source set configuration in the Kotlin DSL
For more details see https://docs.gradle.org/7.1/release-notes.html
------------------------------------------------------------
Gradle 7.1
------------------------------------------------------------
Build time: 2021-06-14 14:47:26 UTC
Revision: 989ccc9952b140ee6ab88870e8a12f1b2998369e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.15 (Oracle Corporation 11.0.15+3)
OS: Linux 5.15.32-1-MANJARO amd64
我更新了以下依赖项:
- org.jetbrains.intellij 从 1.1.4 到 1.5.3
- org.codehaus.groovy:groovy-全部:从 2.5.14 到 3.0.9
也更新了
intellij { version = '2022.1' } // from 2021.2
更新前,测试发现一切正常。
现在,更新后,我收到以下错误:
Task :test FAILED
Execution failed for task ':test'.
No tests found for given includes: fr.nereide.*
我是一个 gradle 菜鸟,我不太清楚它是如何工作的,我发现文档很肤浅。
所以这是我的问题:
- 是否有启动所有测试的简单方法(没有任何限制)
- 我必须添加
@Test
装饰器吗?在更新之前没有必要,并且与当前版本没有太大变化。
- 我在哪里可以找到我可以用来找到我更新的包的迁移信息的文档和信息
- 是否有像 Gradle 这样的傻瓜资源有人可以真正推荐?
提前致谢!
找到问题了,我知道已经有一段时间了。
我用 useJUnitPlatform()
替换了 useJUnit()
和
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
和
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation platform('org.junit:junit-bom:5.8.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
我在 gradle 构建时遇到问题。
这是我的 build.gradle 文件:
import groovy.xml.XmlSlurper
import groovy.xml.MarkupBuilder
def property(String key) { return project.findProperty(key).toString() }
static def definedInPluginXml(String key) {
File pluginXmlFile = new File('src/main/resources/META-INF/plugin.xml')
def idea = new XmlSlurper().parse(pluginXmlFile)
return idea."$key"
}
plugins {
id 'org.jetbrains.intellij' version '1.5.3'
id 'groovy'
id 'java'
id 'org.jetbrains.changelog' version '1.2.1'
}
apply plugin: 'org.jetbrains.changelog'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = '2022.1'
plugins = ['java', 'com.intellij.java', 'org.intellij.groovy']
}
/**
* Refreshes the plugin.xml file for deployment
*/
String ideaMinVersion = property("ideaMinVersion")
String ideaMaxVersion = property("ideaMaxVersion")
String pluginVersion = property("version")
patchPluginXml {
changeNotes = changelog.get(pluginVersion).toHTML()
version = pluginVersion
sinceBuild = ideaMinVersion
untilBuild = ideaMaxVersion
}
test {
useJUnit()
filter{
includeTestsMatching "fr.nereide.*"
}
}
tasks {
runIde {
jvmArgs("-Xmx2048m")
}
}
/**
* Config for changelog Plugin
*/
changelog {
itemPrefix = "-"
keepUnreleasedSection = false
unreleasedTerm = "[Unreleased]"
groups = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"]
}
/**
* Generates the updatePlugin.xml files used for the repo.
*/
task generateUpdatePluginXml {
//...
}
/**
* Adds tests on build
*/
buildPlugin {
dependsOn 'test'
dependsOn 'generateUpdatePluginXml'
tasks.findByName('generateUpdatePluginXml').mustRunAfter 'patchPluginXml'
}
这里是版本信息:
./gradlew --version
Welcome to Gradle 7.1!
Here are the highlights of this release:
- Faster incremental Java compilation
- Easier source set configuration in the Kotlin DSL
For more details see https://docs.gradle.org/7.1/release-notes.html
------------------------------------------------------------
Gradle 7.1
------------------------------------------------------------
Build time: 2021-06-14 14:47:26 UTC
Revision: 989ccc9952b140ee6ab88870e8a12f1b2998369e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.15 (Oracle Corporation 11.0.15+3)
OS: Linux 5.15.32-1-MANJARO amd64
我更新了以下依赖项:
- org.jetbrains.intellij 从 1.1.4 到 1.5.3
- org.codehaus.groovy:groovy-全部:从 2.5.14 到 3.0.9
也更新了
intellij { version = '2022.1' } // from 2021.2
更新前,测试发现一切正常。 现在,更新后,我收到以下错误:
Task :test FAILED Execution failed for task ':test'. No tests found for given includes: fr.nereide.*
我是一个 gradle 菜鸟,我不太清楚它是如何工作的,我发现文档很肤浅。
所以这是我的问题:
- 是否有启动所有测试的简单方法(没有任何限制)
- 我必须添加
@Test
装饰器吗?在更新之前没有必要,并且与当前版本没有太大变化。 - 我在哪里可以找到我可以用来找到我更新的包的迁移信息的文档和信息
- 是否有像 Gradle 这样的傻瓜资源有人可以真正推荐?
提前致谢!
找到问题了,我知道已经有一段时间了。
我用 useJUnitPlatform()
替换了 useJUnit()
和
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
和
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
testImplementation platform('org.junit:junit-bom:5.8.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}