Test coverage different between sonarcloud and intellij


I’m totally new with sonarcloud and I had some difficulties to have my test coverage appears on my dashboard. Editing my pom.xml adding jacoco lines thanks to code found on forums, I finally get it but the result is really different from the one given by intellij (15% in sonarcloud vs 67% in Intellij). Some class are totally detected as 0% whereas they are tested.
Any idea ?


Thanks for your help !

Welcome to the community!

SonarCloud will simply import the coverage from the provided report files, in your example written by jacoco. There are a couple of things you could verify:

  • Pick a class that’s missing coverage on SonarCloud
  • Find the coverage data of that file in jacoco’s report files -> if it’s not in any report file, SonarCloud cannot import it
  • In the output of the scanner in debug mode, find evidence that the report file was actually imported -> if it wasn’t, the coverage in it won’t be passed to SonarCloud

I hope this helps!

1 Like

Ok so my problem is more related with Jacoco than sonar. I’m going to check some tuto to understand how it works and will come back on this ! It’s a pity to not have a full tutorial to explain this part here lol :blush:

Thanks !