现在随着 JUnit 5.0 的发布,我正在努力使用 jacoco 获取代码覆盖率数据。
我的项目是多模块的,我的问题是没有为每个模块创建 exec 文件。根项目中只有一个(看起来几乎是空的)。我一直无法为此找到最新的指南。
我尝试了此处描述的不同方法:Gradle Jacoco 和 JUnit5,但没有任何成功。
是否有人在 JUnit5 和 Jacoco 的多模块(非 Android)Gradle 项目中进行了工作设置?
还是带有 JUnit5 和 Jacoco 的 Gradle Android 项目?任何意见是极大的赞赏。在有一些官方文档可用之前,即使是丑陋的黑客也是受欢迎的。
我的代码的相关部分(至少在命令行和 IDE 中运行 JUnit5 的地方):
<Root> build.gradle:
buildscript {
dependencies {
...
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.0"
}
}
...
apply plugin: 'org.junit.platform.gradle.plugin'
ext.junitVintageVersion = '4.12.0'
ext.junitPlatformVersion = '1.0.0'
ext.junitJupiterVersion = '5.0.0'
subprojects {
apply plugin: "jacoco"
jacoco {
toolVersion = "0.7.6.201602180812"
}
...
junitPlatform {
filters {
engines {
include 'junit-jupiter', 'junit-vintage'
}
tags {
exclude 'slow'
}
includeClassNamePatterns '.*Test', '.*Tests'
}
}
}
...
dependencies {
// org.junit.platform.commons.util.PreconditionViolationException:
// Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath
testCompile("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")
}