Keeping bugs out

November 7th, 2006

The underlying technology behind wishlisting.com is Ruby on Rails. Coming down the home stretch before showing it to people, one of the things we’re focusing on is preventing people from hitting errors, especially when performing basic operations.

Ruby is widely touted as being a dynamic language - which has it’s pros and cons. One of it’s cons is that you have to test everything a lot to make sure that when you make a change, it doesn’t break other things. For example, we started using the conditional caching plugin, got that working, and when we added the querystring action caching plugin, they stomped all over one another, overriding the same methods and not providing any error messages.

In other languages, errors like this would be caught by the compiler. You’d get a broken build, and know immediately that something was wrong. The equivalent in Ruby is to write good, automated, unit and functional test to catch problems. Writing tests is pretty easy - Rails has that baked in. Automating them requires some work. The tools we found worked the best were the continuous_builder plugin. Ryan Daigle has a great article on how to install and configure that plugin here. This plugin will fire off your suite of tests whenever you check code into your repository. That way you can get some amount of satisfaction that what you checked in didn’t break other stuff - at least, to the extent that you wrote tests that covered all of the other stuff.

How do you figure out how much of your code your tests are testing? That’s where code coverage tools come in, the leader in the Ruby space is Rcov. We haven’t gotten there yet, but we will. For a quick and dirty way to keep an eye on how successful your functional and unit tests over time are, Ben Curtis has a cool online tool called Tesly, Jr. You can install a plugin into your codebase that will automatically post your test results up to that site, which will summarize them and produce some little graphs. We’re using it now, and although I’m not yet sold on it’s usefulness, it’s pretty cool and is very easy to install and configure.

Leave a Reply