Jacoco and Unit Tests Code Coverage with android-gradle-plugin >= 1.1

后端 未结 9 855

I recently started integrating android-gradle-plugin 1.1.0 in one of my projects. The project uses robolectric 2.4 to run unit tests.

It\'s

9条回答
  •  [愿得一人]
    2020-12-12 21:36

    You can try to use this Gradle plugin: https://github.com/arturdm/jacoco-android-gradle-plugin

    Basically, all you need to do is apply it like this:

    buildscript {
      repositories {
        jcenter()
      }
      dependencies {
        classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
      }
    }
    
    apply plugin: 'com.android.library' // or 'com.android.application'
    apply plugin: 'jacoco-android'
    

    As a result you should get a JacocoReport task for each variant. Run the command below to generate code coverage reports for all of them.

    $ ./gradlew jacocoTestReport
    

提交回复
热议问题