Jacoco converting coverage.ec to reports without coverage.em

可紊 提交于 2019-11-29 07:49:41

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.

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.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!