6

I have set up SonarQube, Maven and Cobertura to upload unit test coverage at every build run. I want to use the differential views to get coverage for the delta (new code only).

The coverage itself is successfully uploaded, and I can see the delta in lines of code. However, I can't get the "Coverage on new Code" to work.

I tried different values for the leak period, including previous_analysis and previous_version (changing the version from 1.0 to 1.1 in the new analysis). I also used -Dsonar.projectDate to simulate a past date of analysis but still no luck.

Any thoughts?

enter image description here

MisterStrickland
  • 947
  • 1
  • 15
  • 35

3 Answers3

7

The key requirement to obtain new_code -related information/metrics is to leverage SonarQube SCM integration. And to benefit from that you have to install a compatible SCM Plugin applicable to your project (e.g. Git Plugin, SVN Plugin etc.).

Nicolas B.
  • 7,245
  • 17
  • 29
  • That's what I have in mind, but I wanted to create a minimum viable product "manually" first. So you're saying I can't use the `new_code` by manually uploading from the command-line? – MisterStrickland Aug 31 '16 at 14:39
  • 1
    I don't understand your question. All I'm saying is that you should install the [Git Plugin](http://docs.sonarqube.org/display/PLUG/Git+Plugin) (or else depending on the SCM you're using) and verify that SCM integration is enabled in your project settings. That's because *New Code* is detected based on SCM *blame* information. – Nicolas B. Aug 31 '16 at 14:49
  • I installed the Jazz RTC plug-in and the results I'm seeing in SonarQube are the very same - I can see the new lines of code, but no new coverage :( – MisterStrickland Aug 31 '16 at 18:08
  • Interestingly, it's working with Git. I will accept your answer and send a separate question just for jazz. Thanks @Nicolas – MisterStrickland Aug 31 '16 at 18:26
  • I have added `sonar-scm-git-plugin-1.2.jar` to `sonarqube-6.2/extensions/plugins/` since I'm using Git for scm. However, nothing changed. Is that enough? – bsky Feb 20 '17 at 11:02
1

"Coverage on New Code" is only displayed if you are using/activating SCM support (SVN, Git, ...).

sonar.scm.disabled=false

Saikat
  • 14,222
  • 20
  • 104
  • 125
1

Adding this sonar.java.binaries=classes directory, most likely target/classes helped me in fixing this issue. No JaCoCo analysis of project coverage can be done since there is no class files

Nerunja
  • 9
  • 2
  • please consider adding relevant info from your link to the space provided in the answer. – sao Feb 19 '20 at 14:37