2

Is it possible in SonarQube to calculate code coverage for a delta only?

For instance: a project had 1000 lines yesterday and its unit test coverage results are already in SonarQube. A new commit was pushed today with an extra 100 lines of code and additional test cases. These additional test cases cover 70 of the 100 new lines. Is there a way, possibly using TimeMachine, to retrieve/calculate the code coverage for the delta only? (in this case 70%)

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
MisterStrickland
  • 947
  • 1
  • 15
  • 35

1 Answers1

2

You're looking for "Coverage on New Code", which is calculated against the "Leak period", i.e. the first listing in Administration > General > Differential Views.

Your problem is that differential values are calculated during analysis, so you can't update the leak period value and retroactively get exactly what you described. But narrow the leak period value down from the default 30 days (maybe previous_version?) and you'll get close going forward.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • Hi G. Ann. I configured SQ just like you mentioned above. I added 12 new lines of code and a unit test that covers 6 of them. I do see on the home page of my project `+12 lines of code` in the `Size` section, but a `-` (dash) on the `Coverage on the new Code` item. – MisterStrickland Aug 30 '16 at 19:06