2 回答
TA贡献1856条经验 获得超17个赞
首先,创建源集和配置:
sourceSets {
create("intTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}
val intTestImplementation: Configuration by configurations.getting {
extendsFrom(configurations.implementation.get())
}
val intTestRuntimeOnly: Configuration by configurations.getting {
extendsFrom(configurations.runtimeOnly.get())
}
然后,创建任务来运行它们:
val integrationTest = task<Test>("integrationTest") {
description = "Runs integration tests"
group = "verification"
testClassesDirs = sourceSets["intTest"].output.classesDirs
classpath = sourceSets["intTest"].runtimeClasspath
shouldRunAfter("test")
}
此外,您可以添加要由新源集使用的依赖项。例如:
intTestImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
intTestRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
添加回答
举报