vanniktech / gradle-android-junit-jacoco-plugin

Gradle plugin that generates JaCoCo reports from an Android Gradle Project
http://vanniktech.com
Apache License 2.0
400 stars 76 forks source link

Running combinedTestReportDebug always return 0% coverage first time #199

Open nguyenvp08 opened 3 years ago

nguyenvp08 commented 3 years ago

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

vramasam commented 3 years ago

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

volkansahin45 commented 3 years ago

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

vramasam commented 3 years ago

Hello @vanniktech Any suggestions here that would help?

ReginFell commented 3 years ago

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

dsuresh-ap commented 3 years ago

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"

vramasam commented 3 years ago

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.

dsuresh-ap commented 3 years ago

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.

vramasam commented 3 years ago

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

dsuresh-ap commented 3 years ago

@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.