Subject: Code to Test ratio summary is incorrect

Original Post Dan Kubb's Avatar

Dan Kubb

21 Nov, 2009 08:14 AM via web

Here is an example:

http://devver.net/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fdku...

It says the code to test ratio is 0.4:1, but above it shows the code is 427 LOC, and the Test LOC is 1161. The View Stats report shows the LOC numbers, but the ratio is 1:2.7 which is correct.

  1. Support Staff 2 Posted by dan on 21 Nov, 2009 05:13 PM

    dan's Avatar

    We have been having debates about that... I always thing the code to test ratio is a bit hard to read.

    We wanted to display it in one standard format for users and thought the most common thing would be having more code than tests.... so ratios like 2:1 would be easier to read. We found that most of the ratios were looking like 1:0.5, which seemed more confusing. So we flipped it in favor of always having X:1. Which looks better in the case of more code than tests.

    On the project you mention there is less code than tests so you end up with the confusing 0.4:1 which really is the same as 1:2.7 (along with a rounding to keep short numbers).

    Do you think it would be best to always format the ratios in a way that nothing is ever a decimal? Ie there is never a 0.x partial line of code? We could do that, we just thought it might be confusing on graphs like our community graphs to have the ratio with the standardized 1 flip sides.

    http://devver.net/caliper/community#stats

    Anyways let us know your thoughts on this it is still something we have been playing around with but always found a bit confusing and awkward.

    peace,
    Dan

  2. 3 Posted by Dan Kubb on 23 Nov, 2009 05:48 AM

    Dan Kubb's Avatar

    I generally read code to test ratio as meaning "for every 1 line of code, how many lines of tests are there?". So in a well tested project I would expect somewhere between 1:1 to 1:3 on average. A casual search for "code to test ratio" on google shows that it's how this is commonly displayed. I'm sure though., you're finding out that the community doesn't write anywhere near this, so it's probably showing 1:0.5 or less on average.

    Code to test isn't the most important metric by far, but my main reason for reporting it was just to make sure it was consistent between all the reports. For something like this where there is not a clear right or wrong way to display it I think convention trumps personal preference, so I would recommend using the more conventional format 1:N.

  3. Support Staff 4 Posted by Ben on 01 Dec, 2009 03:04 AM

    Ben's Avatar

    Dan,

    Yes, the issue was that when we used the 1:N format, most of the time (unfortunately), it was a fractional N. As a result, we thought it might be clearer to display it as N:1, but your feedback convinced us to go with the more conventional format.

    We just pushed a new version where we reverted to the 1:N format, so I'm going to mark this as resolved. Thanks for the suggestion - keep them coming!

    Ben

Comments are currently closed for this discussion. You can start a new one.