使用 gradle 6.2.2 运行测试时“未收到测试事件”

问题描述 投票:0回答:1

我有一个Java多模块项目,当我运行控制台命令“./gradlew:tests:test”或使用IDEA“test -p测试”或“:tests:test”时,我收到消息“未收到测试事件”。通过 IDEA 和 jUnit5 运行测试效果很好。 我使用 --info 来查看发生了什么。

我的项目: Java 1.8; 朱尼特5; 摇篮6.2.2

我发现我的任务 :tests:testClass 被跳过,因为它没有任何操作。我想我的测试类路径可能有一些问题。不过看起来好像还可以啊

我的build.gradle.kts

configure<QualityExtension> {
  configDir= "$gradleScriptDir/quality"
  sourceSets = listOf(
    project.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME),
    project.sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME))
}

我的junitPlatformBuild

configure(allprojects) {
group = "ru.*"
version = version

tasks.withType(Test::class) {
    ignoreFailures = true

    useJUnitPlatform {

        systemProperty("web.webdriver.remote", "true")

        if ("true" == System.getProperty("parallel")) {
            systemProperty("junit.jupiter.execution.parallel.enabled", "true")
            systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent")
        }

        includeTags = (System.getProperty("includeTags") ?: "none").split(',').toSet()
        excludeTags = (System.getProperty("excludeTags") ?: "WIP,debug").split(',').toSet()
        (System.getProperty("params") ?: "")
                .split(',')
                .forEach { p ->
                    systemProperty(
                            p.split(':').get(0).trim(),
                            p.split(':').getOrElse(1) { "" }.trim())
                }
    }
}

}

因此,SourceSet.MAIN_SOURCE_SET_NAME = "main" 和 SourceSet.TEST_SOURCE_SET_NAME = "test"。 我的工作目录是“tests/src/test/java”。看起来 SourceSet 应该没问题。有什么想法可能是错的吗?

gradle testing junit5
1个回答
0
投票

如果您没有为调用设置

includeTags
系统属性,那么您实际上会执行
includeTags = "none"
,这可能会导致实际上没有执行任何测试。

© www.soinside.com 2019 - 2024. All rights reserved.