Jacoco converting coverage.ec to reports without coverage.em

后端 未结 4 1526
死守一世寂寞
死守一世寂寞 2020-12-18 09:09

I was able to get the code coverage report by following the steps below,

  1. Enable coverage on the build type you want (e.g. debug)

    buildTypes {

相关标签:
4条回答
  • 2020-12-18 09:32

    To get the coverage out of coverage.ec file just rename it to coverage.exec and the open it with "Show coverage data" option

    "Show coverage data" can be found under "Analyze" option in Android Studio.

    Verified this with Android Studio 3.3

    0 讨论(0)
  • 2020-12-18 09:43

    Simply use the "coverage.ec" as the ".exec" file, it's worked for me

    This is what Google did in Android Gradle Plugin source code.

    public static final String FILE_COVERAGE_EC = "coverage.ec";

    in SimpleTestCallable.java under com.android.builder.internal.testing package.

    0 讨论(0)
  • 2020-12-18 09:48

    Remove . from following command its work for me

    java -jar android-jacoco-the-missing.jar -f /path/to/coverage.ec -p /path/to/android/project
    
    0 讨论(0)
  • 2020-12-18 09:54

    I wrote an article about the same scenario and my solution. You can read it here. For answering this specific question you should do the following steps: Change gradle to this:

    apply plugin: 'jacoco'
    jacoco {
       toolVersion = '0.7.5.201505241946'
    }
    

    Second download this jar. Continue with the things you did until you have coverage.ec file. Then when you have it run:

    java -jar android-jacoco-the-missing.jar -f /path/to/coverage.ec -p ./path/to/android/project
    

    And thats it! The jar will generate a folder with the code coverage.

    Another option is to use the coverage.ec with the Jenkins Jacoco plugin. But for that you need to have Jenkins set on.

    0 讨论(0)
提交回复
热议问题