Fix recording of code coverage

This commit is contained in:
Gary Tierney
2018-08-20 01:29:52 +01:00
parent 37547ee3aa
commit 5d84cdf40f
4 changed files with 47 additions and 44 deletions
+6
View File
@@ -18,6 +18,12 @@ dependencies {
implementation group: 'io.github.classgraph', name: 'classgraph', version: classGraphVersion implementation group: 'io.github.classgraph', name: 'classgraph', version: classGraphVersion
implementation group: 'com.lambdaworks', name: 'scrypt', version: scryptVersion implementation group: 'com.lambdaworks', name: 'scrypt', version: scryptVersion
test.useJUnitPlatform()
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitJupiterVersion
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitJupiterVersion
testImplementation group: 'org.junit.vintage', name: 'junit-vintage-engine', version: junitVintageVersion
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: junitPlatformVersion
testImplementation group: 'junit', name: 'junit', version: junitVersion testImplementation group: 'junit', name: 'junit', version: junitVersion
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: powermockVersion testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: powermockVersion
testImplementation group: 'org.powermock', name: 'powermock-api-mockito', version: powermockVersion testImplementation group: 'org.powermock', name: 'powermock-api-mockito', version: powermockVersion
+4
View File
@@ -2,6 +2,10 @@ subprojects { subproj ->
if (subproj.buildFile.exists()) { if (subproj.buildFile.exists()) {
apply plugin: 'apollo-plugin' apply plugin: 'apollo-plugin'
test {
useJUnitPlatform()
}
dependencies { dependencies {
test.useJUnitPlatform() test.useJUnitPlatform()
implementation group: 'com.google.guava', name: 'guava', version: guavaVersion implementation group: 'com.google.guava', name: 'guava', version: guavaVersion
+37 -43
View File
@@ -1,59 +1,53 @@
apply plugin: "jacoco" apply plugin: 'jacoco'
def testedProjects() {
subprojects.findAll { subproject -> subproject.plugins.hasPlugin('java') || subproject.plugins.hasPlugin('kotlin') }
}
gradle.projectsEvaluated {
configure(testedProjects()) {
apply plugin: 'jacoco'
allprojects {
tasks.withType(Test) {
jacoco { jacoco {
toolVersion = '0.8.1' toolVersion = '0.8.1'
} }
afterEvaluate { jacocoTestReport {
jacocoTestReport { sourceDirectories = files(sourceSets.main.allSource.srcDirs)
dependsOn tasks.test classDirectories = files(sourceSets.main.output)
}
sourceSets sourceSets.main test {
reports { jacoco {
html.enabled = true append = false
xml.enabled = true destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
csv.enabled = false classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
} }
} }
} }
}
task jacocoTestReport(type: JacocoReport) { task jacocoTestReport(type: JacocoReport) {
sourceDirectories = files() def tests = []
classDirectories = files() def sourceDirs = files()
executionData = files() def classDirs = files()
def execData = files()
reports { testedProjects().each { subproject ->
html.enabled = true sourceDirs += files(subproject.sourceSets.main.allSource.srcDirs)
xml.enabled = true classDirs += files(subproject.sourceSets.main.output)
csv.enabled = false execData += files(subproject.tasks.jacocoTestReport.executionData.findAll {
} it.exists()
})
// Work-around to allow us to build list of executionData files in doFirst tests += subproject.tasks.test
onlyIf = {
true
}
/*
* Builds list of source dirs, class dirs, and executionData files
* when task is run, not at script evaluation time
*/
doFirst {
subprojects.findAll { subproject ->
subproject.pluginManager.hasPlugin('java') || subproject.pluginManager.hasPlugin('kotlin')
}.each { subproject ->
additionalSourceDirs files((Set<File>) subproject.sourceSets.main.allJava.srcDirs)
additionalClassDirs((FileCollection) subproject.sourceSets.main.output)
if (subproject.pluginManager.hasPlugin('jacoco')) {
executionData subproject.tasks.jacocoTestReport.executionData
}
} }
executionData = files(executionData.findAll { dependsOn tests
it.exists() sourceDirectories = sourceDirs
}) classDirectories = classDirs
executionData = execData
} }
} }
-1
View File
@@ -35,5 +35,4 @@ def processPluginDir(Path pluginDir) {
} }
pluginDirs.each { processPluginDir(it) } pluginDirs.each { processPluginDir(it) }
include 'test-plugin'