Forum: Ruby on Rails rake stats: code to test ratio

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel S. (Guest)
on 2007-01-09 02:56
I was curious what everyone's code to test ratio is with running rake
stats.  I'm trying to find what a typical ratio should be.
Phlip (Guest)
on 2007-01-09 04:43
(Received via mailing list)
Daniel Salo wrote:

> I was curious what everyone's code to test ratio is with running rake
> stats.  I'm trying to find what a typical ratio should be.

  Code LOC: 2233     Test LOC: 2173     Code to Test Ratio: 1:1.0

Note if this were a greenfield project (no legacy stuff like HTML to
slow it
down) the test rate would be much higher...

--
  Phlip
  http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Jeff C. (Guest)
on 2007-01-09 06:29
(Received via mailing list)
Phlip wrote:
> Daniel Salo wrote:
>   Code LOC: 2233     Test LOC: 2173     Code to Test Ratio: 1:1.0
>
> Note if this were a greenfield project (no legacy stuff like HTML to slow it
> down) the test rate would be much higher...
>

I hate any comparisons that involve lines of code.

For a while when I first discovered rake stats, I justified it to
myself by saying well, they're only using it to get a ratio, not
absolute lines of code; so it must be ok.

But lately I've decided that it's still ridiculous.  How can lines of
code at all compare to lines of testing code?

If it takes me 6 lines to implement a method, do I really have to come
up with 6 or more assertions to get the ratio right?  What if two
assertions test everything I need to about that method?  Or what if I
really need 10, then 6 is actually not enough.

So please don't strive for any particular ratio.  It's just there for
informational purposes, no more and no less.

Jeff
softiesonrails.com
Andrew S. (Guest)
on 2007-01-09 07:23
Daniel Salo wrote:
> I was curious what everyone's code to test ratio is with running rake
> stats.  I'm trying to find what a typical ratio should be.

It may be interesting, but it is not informative or useful.  The number
of tests and the number of lines in those tests should reflect what is
required to ensure your application is working correctly.

In a similar way, the number of lines in the application is sort of
interesting but has little bearing on the functionality or usability the
application may have.

The only time I have used either of these numbers is to demonstrate how
efficient rails is in comparison to another platforms.  Striving for a
particular number or ratio is fruitless IMHO.
Russell N. (Guest)
on 2007-01-09 14:23
(Received via mailing list)
I agree with you, Jeff. It's just numbers really. A guide. You know if
you're testing enough 'cause you're testing a lot. As a newcomer to
using
"rake stats", I was obsessed by getting that ratio above 1:1.0. I soon
discovered that [kinda counterintuitively] the DRYer you make your tests
[ie, writing out common assertions to test_helper.rb, etc] the LOWER
your
ratio will be. Good DRY tests ratio looks a lot worse than a repetitive,
redundant [yes, I know] one. I still use "rake stats" but only out of
curiosity instead of looking for a validation of how good a coder I'm
being.
[Yes, I need affirmation like that sometimes.]

RSL
Phlip (Guest)
on 2007-01-09 15:04
(Received via mailing list)
Jeff wrote:

> > Note if this were a greenfield project (no legacy stuff like HTML to slow it
> > down) the test rate would be much higher...

> I hate any comparisons that involve lines of code.

Our industry in general is recovering from the days when bosses tracked
LOC as "progress".

Just between engineers, as a ratio, when we are curious, it's project
information like any other...

--
  Phlip
This topic is locked and can not be replied to.