Test-driven code duplication

Friday 18 April 2003 at 14:59

Thursday, I was test driving a DAO. At the moment it's almost entirely pseudo implementation -- no actual SQL. The interface is already designed, I get to write the SQL.

Unit testing the SQL is causing code duplication. I'm using EasyMock objects for the Connection, Statement, PrepairedStatement, and ResultSet. I end up basically writing the implementation in the test and then writing it again in the DAO. Something stinks. I think it has to do with the way EasyMock sets expectations. It would look differently if I used MockObjects, or if I rolled my own mocks. But EasyMock saves me the extra work of writing and maintaining the mock objects.

I want these tests to be independent of the database.