1

我正在尝试Gradle with Kotlin DSL为我的项目进行配置。它由两个模块组成。模块 A是一个简单的Java 11应用程序。模块 B包含Kotlin使用Spek.

我想配置 gradle 以便gradle test不运行验收测试,并且这些测试仅与 task 一起运行gradle acceptanceTest。我在下面尝试了其他过滤器变体的配置,包括和排除但没有运气。我错过了什么?

tasks.withType<Test> {
    println("always printed: configuration phase test")

    useJUnitPlatform()

    filter {
        exclude("acceptance.*")
    }

    doLast {
        println("only printed if executed: execution phase test")
    }

}

val acceptanceTest: Task by tasks.creating(Test::class) {
    println("always printed: configuration phase ac")

    useJUnitPlatform {
        includeEngines("spek2")
    }

    filter {
        include("acceptance.*")
    }

    doLast {
        println("only printed if executed: execution phase ac")
    }
}
4

1 回答 1

-1

过滤器是不必要的。我只是acceptanceTest在错误的地方完成了任务......移动到acceptance模块后,它按预期工作。

于 2019-02-17T08:54:10.643 回答