Ruby and dead simple code coverage

October 14, 2008 📬 Get My Weekly Newsletter

I haven't used a code coverage tool for Java, but in my spare time I've been working up some Ruby code (mostly to learn the language). I'm using Test Driven Development, which is slightly simpler with Ruby than with Java (mostly due to Ruby's interpreted nature).

I had heard about rcov and decided to give it a shot. Within literally 5 minutes I had it installed and a report showing my tests were not covering all my code! Amazing. I could then easily see exactly where I need to to test and, sure enough, found some bugs that would've gone unnoticed.

Even the best tool with Java would've required some painful ant tweaking (not to mention hopes and prayers that it worked with TestNG). I already cannot imagine writing tests without being able to view the coverage....