dimanche 26 avril 2015

What is the best way to filter JaCoCo coverage reports using Gradle?

Problem:

I have a project on Github that uses JaCoCo for coverage reports. I have a few packages that I do not have tests written for just yet which conflicts with the existing code coverage that I do have tests for.

Related Documentation:

I have read the following documentation:

Official JaCoCo site: http://ift.tt/1GnmYTR

Official JaCoco docs for Gradle: http://ift.tt/1bJq0dq

Official JaCoCo Github issues, working on coverage: http://ift.tt/1GnmYTS http://ift.tt/1bJq0ds

Related StackOverflow Links:

JaCoCo & Gradle - Filtering Options (No answer)

Exclude packages from Jacoco report using Sonarrunner and Gradle (Not using Sonar)

JaCoCo - exclude JSP from report (It seems to work for Maven, I am using Gradle)

Maven Jacoco Configuration - Exclude classes/packages from report not working (It seems to work for Maven, I am using Gradle)

JaCoCo gradle plugin exclude (Could not get this to work)

Gradle Jacoco - coverage reports includes classes excluded in configuration (Seems very close, it used doFirst, did not work for me)

Tried:

apply plugin: 'java'
apply plugin: 'jacoco'

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
}

repositories {
    jcenter()
}

jacocoTestReport {
    reports {
        xml {
            enabled = true // coveralls plugin depends on xml format report
        }

        html {
            enabled = true
        }
    }

    test {
        jacoco {
            append = false
            destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
            classDumpFile = file("$buildDir/jacoco/classpathdumps")
            excludes = ["projecteuler/**"] // <-- does not work
            // excludes = ["projecteuler"]
        }
    }
}

Question:

How can I exclude certain packages and classes when generating the JaCoCo coverage reports?

Aucun commentaire:

Enregistrer un commentaire