Wednesday, January 25, 2006

DBUnit

I've recently decided to take the leap and add db unit tests to my regular set of unit tests for the project I'm working on. In the past, I've always dodged these sort of tests. I'm hardly alone - most people don't like to think about this, since it can get pretty messy. However, it's pretty bogus to not put in db tests, when typically, most apps involve a database. In fact, other than smaller one-off applications, and small scripts, I cannot think of any application I've worked on in my career of 12+ years that didn't have a database.

Anyway, I decided to use DBUnit, since I'm using JUnit already. I decided to just crawl before trying to walk or run, and just do a simple compare of the expected data over a set of tables. DBUnit made this easier than it would have been otherwise. It wasn't without its frustrations. It took me a while, but over the course of a few days at work (doing other tasks, too) I was able to get the compare to work, incorporated into the battery of tests run by CruiseControl, and now I think I can add new tests if/when they seem warranted.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?