Way to get Gradle Jacoco to Output Coverage to Console?

Viewed 285

In python, using Coverage.py we are able to get line information about code coverage on the command line using coverage report --show-missing. This showed what lines of each file weren't being covered.

Using gradle plugins, the best output I can get is:

- Class Coverage: 10% 
- Method Coverage: 3.2% 
- Branch Coverage: 100% 
- Line Coverage: 1.2% 
- Instruction Coverage: 1.1% 
- Complexity Coverage: 3.2%

However as this does not give line information, you may as well just look at html output.

My test.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
}

plugins {
    id 'application'
    id 'jacoco'
    id 'com.github.ksoichiro.console.reporter' version '0.6.2'
    id 'org.barfuin.gradle.jacocolog' version '1.2.4'
}

dependencies {
    implementation files('lib/json.jar')
    implementation files('lib/junit-platform-console-standalone-1.7.0-M1.jar')
    implementation files('lib/jsonassert-1.2.3.jar')
}

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport // report is always generated after tests run
    ignoreFailures = true
}
test.outputs.upToDateWhen {false}

jacocoTestReport {
    dependsOn test // tests are required to run before generating the report
}

repositories {
    mavenCentral()
}

group 'unsw.blackout'

apply plugin: 'java'

sourceSets.test.java.srcDirs = ['src']
sourceSets.test.java.excludes = ['degree/*']
sourceSets.main.java.srcDirs = ['src']
sourceSets.main.java.excludes = ['degree/*']

Is there an equivalence for gradle?

0 Answers
Related