Cucumber Code Ratio

14 December 2009 in Agile Practice, Debugging, Distraction, Testing

I wrote a quick and dirty rake task for grabbing the code ratio for cucumber. Here’s what I got for our one sprint old project:

Code Lines: 379
Test Lines: 431
Code to Test Ratio: 1.1

Update: Here is the ratio from a much larger project posted by co-worker, Clayton Ziingletwitch (thats “Clayton Lengel-Zigich” for those who don’t appreciate childish mockery. But come on Clayton, there’s so few names in the world, it just seems selfish to have so many):

Code Lines: 7443
Test Lines: 9593
Code to Test Ratio: 1.3

Generally I don’t care about test ratio, but I was interested in how many lines of test code it takes go get good coverage with cucumber vs. rspec. We are getting 87.7% code coverage with a 1.1 ratio. With rspec we would be looking at around 3:1 ratio to get similar coverage. Two thirds less test code to get high coverage? I’ll take it.

Here’s the code to generate the stats if anyone wants to use it. Just drop it in your project’s lib/tasks folder. The code assumes the default cucumber features folder setup.

Of course most BDDers will say that it isn’t enough to test with only cucumber - but I’m beginning to think that jumping to unit testing for every bit of code we write is akin to premature optimization. Regardless, I hope that anyone who has been burned in the past and is not testing because they are on a tight deadline: please consider fishing this baby out of the bath water.

Tags: , , ,

1 Comment to Cucumber Code Ratio

  1. Here are the stats for my big project:

    Code Lines: 7443
    Test Lines: 9593
    Code to Test Ratio: 1.3

    Neat!

  2. clayton on 14 December 2009

Leave a comment



Tweets

  • Tobi:
    ^^ shit, ok now I see it's not your fault, its (my...
  • Tobi:
    Thanks for this great writeup! btw. you missed...
  • Chris Young:
    Thanks for letting me know. I updated the link....
  • maxjgon:
    The link of the project in Github is broken!...
  • Chris Young:
    Oh I see . . . Maybe I should check out this so-c...