SonarQube: Coverage on New Code never calculated
Asked Answered
K

3

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

Kokoschka answered 30/8, 2016 at 21:50 Comment(0)
B
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.).

Bradley answered 31/8, 2016 at 6:30 Comment(5)
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?Kokoschka
I don't understand your question. All I'm saying is that you should install the 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.Bradley
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 :(Kokoschka
Interestingly, it's working with Git. I will accept your answer and send a separate question just for jazz. Thanks @NicolasKokoschka
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?Oresund
F
1

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

sonar.scm.disabled=false

Freewheeling answered 6/6, 2018 at 9:53 Comment(1)
What is it? What's that for, why we should disable it?Taperecord
M
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

Melamine answered 19/2, 2020 at 14:6 Comment(1)
please consider adding relevant info from your link to the space provided in the answer.Embay

© 2022 - 2024 — McMap. All rights reserved.