JaCoCo doesn't work with Robolectric tests

前端 未结 5 534
Happy的楠姐
Happy的楠姐 2021-01-01 12:38

I wanted to generate code coverage reports on my JUnit tests in my android project so I added the JaCoCo gradle plugin. This is my project level build.gradle fi

5条回答
  •  囚心锁ツ
    2021-01-01 12:56

    It is known issue with the possible workaround - https://github.com/jacoco/jacoco/pull/288

    Or downgrade jacoco version to 0.7.1.201405082137

    UPDATE

    The workaround is not needed anymore. You must use gradle version 2.13 and jacoco version 0.7.6.201602180812.

    Update root build.gradle:

    buildscript {
        dependencies {
            classpath 'org.jacoco:org.jacoco.core:0.7.6.201602180812'
        }
    }
    
    task wrapper( type: Wrapper ) {
      gradleVersion = '2.13'
    }
    

    Run ./gradlew wrapper

    Update project build.gradle:

    apply plugin: 'jacoco'
    
    android {
      testOptions {
        unitTests.all {
          jacoco {
            includeNoLocationClasses = true
          }
        }
      }
    }
    

提交回复
热议问题