我正在尝试按照https://techblog.tbauctions.com/kotlin-azure-and-code-coverage/的建议在gradle Kotlin中集成代码覆盖率,但是它不起作用,下面是项目文件。
build.gradle.kts
plugins {
jacoco
}
val test by tasks.getting(Test::class) {
useJUnitPlatform { }
}
tasks.withType(JacocoReport::class.java).all {
reports {
xml.isEnabled = true
xml.destination = File("$buildDir/reports/jacoco/report.xml")
}
}
tasks.withType<Test> {
jacoco {
toolVersion = "0.8.3"
reportsDir = file("$buildDir/reports/jacoco")
}
finalizedBy("jacocoTestReport")
}
错误-在项目':app'中找不到名称为'test'的任务
还尝试了https://docs.gradle.org/current/userguide/jacoco_plugin.html
最佳答案
How to generate and publish Code Coverage in gradle kotlin using Azure DevOps?
根据错误信息:
Error - Task with name 'test' not found in project ':app'
项目中似乎没有提供名为
test
的任务。在Gradle中使用JVM语言插件(如Java)时,会自动提供一个名为test的任务。默认情况下,此任务在src/test
下运行所有测试。Java插件向您的项目添加了许多任务,包括
test
任务:The Java Plugin:
因此,请确保已在Gradle中添加了Java插件。
您可以检查this document了解更多详细信息。
希望这可以帮助。
关于android - 如何使用Azure DevOps在Gradle Kotlin中生成和发布代码覆盖率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60723205/