# Rake stats: code to test ratio

**URL:** <https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425>\
**Category:** Rails\
**Created:** [January 9, 2007, 1:56am UTC](https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425 "2007-01-09T01:56:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [January 9, 2007, 1:56am UTC](https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425/1 "2007-01-09T01:56:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [January 9, 2007, 3:43am UTC](https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425/2 "2007-01-09T03:43:17Z")

</div>

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  
[Redirecting...](http://www.greencheese.us/ZeekLand) ← NOT a blog!!!

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [January 9, 2007, 5:29am UTC](https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425/3 "2007-01-09T05:29:25Z")

</div>

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

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [January 9, 2007, 6:23am UTC](https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425/4 "2007-01-09T06:23:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [January 9, 2007, 2:04pm UTC](https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425/5 "2007-01-09T14:04:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [January 9, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/rake-stats-code-to-test-ratio/81425/6 "2007-01-09T13:23:24Z")

</div>

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
