Skip to content

sdklite/jacoco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

JaCoCo gradle plugin is used to generate code coverage reports for Android project, it creates JaCoCoReport task for the variants which buildType.testCoverageEnabled is true.

Getting Started

  1. Config JaCoCo gradle plugin in build.gradle of root project.

    buildscript {
        repositories {
            ...
            jcenter()
        }
        dependencies {
            ...
            classpath 'com.sdklite.jacoco:gradle:0.1.0'
        }
    }
  2. Apply JaCoCo gradle plugin in build.gradle of android project

    apply plugin: 'com.sdklite.jacoco'
    
    android {
        ...
        buildTypes {
            debug {
                ...
                testCoverageEnabled true
            }
            ...
        }
    }
    
    jacocoUnitTestReport {
        csv.enabled false
        xml.enabled false
        html.enabled true
    }

    The plugin excludes Android generated classes from report by default. You can specify custom exclusion patterns by jacocoUnitTestReport:

    jacocoUnitTestReport {
        ...
        excludes += [
            '**/AutoValue_*.*',
            ...
        ]
    }
  3. Generate coverage report

    $ ./gradlew jacocoTestReport

Example