Code Coverage On New Code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Code Coverage On New Code

softwareforums2013
Hi Everyone,

I would like to understand how "Code Coverage On New Code" works in Sonar. Is there any difference, on "Code Coverage On New Code" functionality between Sonar Version 3.2.1 and Sonar Version 5.0.1.

We are using Sonar Version 3.2.1 and planning to upgrade to 5.0.1 soon.

I have an example/scenario where I would like to understand if this will give us Code Coverage On New Code because currently in our Sonar Dashboard we are seeing No New Lines to Cover.

We use SVN for our Code Repository. Lets say we created a new branch 7.1.0 on Jan 1 2015 but for some reason we are behind on running sonar analysis on the day branch was created. Lets say we started our sonar analysis for 7.1.0 branch on Feb 1 2015, which means we are 1 month behind. Let July 1 2015 is code cut off day.

Now, I have performed below steps inorder to get correct report on "Code Coverage On New Code" for 7.1.0 branch but I am not sure if I am correct or not. I am not sure if Sonar will give Correct Report or not peforming below steps.

We got the Revision Number for first day of our daily build for 7.1.0 branch or Revision Number of code cut off day for the branch before 7.1.0. Either way the code should be same.

We ran sonar analysis against this Revision Number which means the code is from the first day of 7.1.0 branch. We changed our sonar project name during these analysis, so this way it will create a new project in sonar dashboard.

After first sonar analysis, we got the result in sonar dashboard.

Now we run another or final sonar analysis against the latest code of 7.1.0 branch or the last day of code checkin.

After Second round of sonar analysis is completed, we are not seeing "Code Coverage on New Code". It prints a message "No New Lines to Cover".

So, my question here is how does sonar knows, when new code is added. As per my understanding since, we ran 2 sonar analysis, first analysis against first day of branch creation using revision number and 2nd analysis against last day of branch or code cut off day. And there were lots of check-in done during those 2 revision number. Why is sonar not able to find out new lines of code.

If sonar find new lines of code added from Repository, than it should be able to find those new lines of code added.

This new code coverage is very important and I really would like to know behind the scene of it.

Reply | Threaded
Open this post in threaded view
|

Re: Code Coverage On New Code

Julien HENRY
Hi,

Coverage on new code is based on svn annotate date.

Say current date is 1st of June.
Say you have 2 differential periods:
  - since previous version
  - since 30 days
Say previous version was released and analyzed in SQ on the 1st of January 2015.

Say svn annotate file1.java returns:
  2015-06-01 line1
  2015-05-15 line2
  2015-04-10 line3
  2015-03-10 line4
  2014-12-31 line5

If you select differential period "since 30 days" then new code will be lines 1, 2
If you select differential period "since previous version" then new code will be lines 1, 2, 3, 4

Does it make sense?

++

Julien
Reply | Threaded
Open this post in threaded view
|

Re: Code Coverage On New Code

softwareforums2013
This post has NOT been accepted by the mailing list yet.
yes and thank you for the response and sorry for the late reply