gradle-android-junit-jacoco-plugin icon indicating copy to clipboard operation
gradle-android-junit-jacoco-plugin copied to clipboard

Running combinedTestReportDebug always return 0% coverage first time

Open nguyenvp08 opened this issue 3 years ago • 9 comments

Dear,

I am using your library to generate test report from both Android tests and local tests, and then push the coverage report to sonarqube, but I often have to run the "combinedTestReportDebug" task twice, because the first time task will generate 0% coverage report, the second time running task will generate correct report coverage percentage

nguyenvp08 avatar Jul 02 '21 11:07 nguyenvp08

Hi, I am always getting zero percentage coverage with Java11 and AGP 7.x.x. Any inputs here that help us?

vramasam avatar Jul 09 '21 12:07 vramasam

I am not %100 percent sure but I had the same problem when I was implementing Coverage Reports in Sonarqube.

volkansahin45 avatar Jul 13 '21 12:07 volkansahin45

Hello @vanniktech Any suggestions here that would help?

vramasam avatar Jul 23 '21 11:07 vramasam

You can check this reply from Google https://issuetracker.google.com/issues/191774966

ReginFell avatar Aug 11 '21 13:08 ReginFell

We had ported this plugin from Groovy to Kotlin and our coverage broke as well on Java11 and AGP 7.x.x. The unit test coverage path for combined tests was incorrect. We had to change "jacoco/test${sourceName.capitalize()}UnitTest.exec" to "outputs/unit_test_code_coverage/${sourceName}UnitTest/*.exec"

dsuresh-ap avatar Aug 26 '21 13:08 dsuresh-ap

Hello @dsuresh-ap . Can you please explain the above change. I believe the above path is something related to sonar. if not so, please let me know where we have to do the change as part of this plugin.

vramasam avatar Aug 31 '21 10:08 vramasam

Hey @vramasam, the line in this plugin is https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/blob/master/src/main/groovy/com/vanniktech/android/junit/jacoco/GenerationPlugin.groovy#L239.

This is where Jacoco looks for JVM unit test coverage. After running the plugin and you go to the /build directory you should see that there is no .exec file in the path the plugin specifies.

dsuresh-ap avatar Aug 31 '21 12:08 dsuresh-ap

Ohh okay got it. Thank you @dsuresh-ap . Any plan to raise PR for this and make a release, any idea on that?

vramasam avatar Aug 31 '21 12:08 vramasam

@vramasam Unfortunately we have re-wrote the plugin in Kotlin and changed a few things around specifically for our app. So I am not sure if our changes will work for all users.

dsuresh-ap avatar Aug 31 '21 13:08 dsuresh-ap