Jacoco + JUnit5

510 views
Skip to first unread message

alix....@gmail.com

unread,
Sep 20, 2017, 8:16:23 AM9/20/17
to SonarQube
Hi,

I have a Gradle (Android) project and I am in the process of getting code coverage (through Jacoco) correctly reported to SonarQube in an Android project using JUnit5 and would like your help to reason what is going wrong.
The problem that I'm experiencing is that code coverage is only reported for the JUnit4 tests in SonarQube.
My .exec files contain all the information about coverage of both JUnit4 and JUnit5 tests (referenced through sonar.jacoco.reportPath) according to my IDE. As for the test reports (referenced through sonar.junit.reportsPath) I believe that there is an issue: https://github.com/aurae/android-junit5/issues/17

To speed things up (determine where the problem is) I wanted to check with you how SonarQube computes code coverage. Is it correct that the two reports (jacoco and junit) are combined to form the final result? Basically, confirming that the exec file might be complete but SonarQube still showing lower coverage numbers if the test report is not complete?
I appreciate your help in this.

Regards
Alix


Nicolas Peru

unread,
Sep 20, 2017, 9:38:12 AM9/20/17
to alix....@gmail.com, SonarQube
Hi alix, 

To be clear  : sonar.junit.reportsPath expects the surefire reports which are XML files pointing out information of test run (success/failure time etc.). This is known as Unit test results.

This has nothing to do with coverage.

Coverage is fed to SonarQube based on the binary report computed by JaCoCo that you generate on your side. 
So to answer your question : as those two things are unrelated, your problem is not what you suppose it is.

So why are you lacking some coverage in SonarQube ? Actually it is a bit hard to answer this : what is your problem exactly : how do you know this relates to Junit5 tests only ? how is your project structured and analyzed ? What do you see in the log of the analysis regarding JaCoCo  ? 

Cheers. 





--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/77cd7ba7-a3a7-4f1b-9841-27e9c57ea291%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Nicolas Peru | SonarSource

alix....@gmail.com

unread,
Sep 20, 2017, 10:27:31 AM9/20/17
to SonarQube
Hi Nicolas,

Thanks for clarifying how it works. It seems that I was wrong about the exec file (or rather, I had forgotten to uncheck an older exec file when loading coverage data) containing JUnit5 coverage. There is no such coverage which explains why I'm not seeing it in SonarQube.
So the mystery is solved!

/ Alix
Reply all
Reply to author
Forward
0 new messages