Unit testing has become second hand to many developers lately. I strive to keep my jUnit coverage as high as possible, and my unit tests as relevant as possible. But over the years, I've consistently run into one nagging problem. How do you unit test code that interacts with a database?
The answer, on the surface, is a simple one: write a unit test that calls a method and check its result. But, that means whomever builds your project needs to have access to the appropriate database, either that, or build without testing. So the alternative is to "mock" up the database connection and "pretend" to make calls to the database. I've had good success using MockObjects to do just that, but ran aground again when I found out that MockObjects doesn't support callable statements very well. That's okay though, because even if it did, your bypassing a large portion of logic that, in this case, is running as a stored procedure. What good it testing a method that does nothing but shove off responsibility to a database that the build environment may not have access to?
Maybe this falls more into the integration testing realm, where it can be assumed that you have a connected database. That does nothing for the large red line in my coverage report though :(
Thursday, April 28, 2005
Monday, April 18, 2005
Bobby Shaftoe
Admirers of Cryptonomicon, and maybe The Baroque Cycle (here, here, and here) may be interested in this rhyme I stubmled upon in one of my daughter's nursery rhyme books this weekend...
Bobby Shaftoe's gone to sea,
Silver buckles at his knee;
He'll come back and marry me,
Bonny Bobby Shaftoe.
Bobby Shaftoe's bright and fair,
Combing down his yellow hair,
He's my ain for ever mair,
Bonny Bobby Shaftoe.
Bobby Shaftoe's tall and sIim,
He's always dressed so neat and trim,
The lassies they all keek at him,
Bonny Bobby Shaftoe.
Bobby Shaftoe's gett'n a bairn,
For to dandle on his airm,
On his airm and on his knee,
Bobby Shaftoe loves me.
A little research reveals that this is a Northumbrian folk song. Interesting.
Bobby Shaftoe's gone to sea,
Silver buckles at his knee;
He'll come back and marry me,
Bonny Bobby Shaftoe.
Bobby Shaftoe's bright and fair,
Combing down his yellow hair,
He's my ain for ever mair,
Bonny Bobby Shaftoe.
Bobby Shaftoe's tall and sIim,
He's always dressed so neat and trim,
The lassies they all keek at him,
Bonny Bobby Shaftoe.
Bobby Shaftoe's gett'n a bairn,
For to dandle on his airm,
On his airm and on his knee,
Bobby Shaftoe loves me.
A little research reveals that this is a Northumbrian folk song. Interesting.
Subscribe to:
Posts (Atom)