Now with the release of JUnit 5.0 I'm struggling to get code coverage data using jacoco.
My project is multi-module and my problem is that there is no exec file created for each module. Only one in the root project (which seems almost empty). I've not been able to find an up-to-date guide for this.
I've tried different approaches described here: Gradle Jacoco and JUnit5 without any success.
Does anyone have a working setup in a multi-module (non-Android) Gradle project with JUnit5 and Jacoco?
Or a Gradle Android project with JUnit5 and Jacoco? Any advice is greatly appreciated. Even ugly hacks are welcome until there is some official documentation available.
Relevant part of my code (where running JUnit5 works both in commandline and from the IDE at least):
<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}")
}