Lately, since I’ve started programming the .NET framework, I’ve become more and more interrested again in test driven development. Usually I’ve to write a lot of data access code but I never really found out a good way to unit test it. Luckily, Roy Osherove has written a very nice article about it on his blog. His solution is very elegant and seems to work like a charm on SQL server but unfortunately (according to the feedback on that article) there are some problems when trying to use this approach on another DBMS.
Leave a comment
You must be logged in to post a comment.
Here’s a small update on my post. It seems that TDD & databases still remains somewhat of an unresolved issue. Besides some of the problems already mentioned in the post and original article there are some other issues so it seems there isn’t a definitive solution to this problem yet. It’s still a pretty hot topic though so hopefully one or more clever minds may come up with something.
You might try looking at MBUnit. Peli has a blog on: http://blog.dotnetwiki.org/archive/2004/07/11/673.aspx and later at: http://blog.dotnetwiki.org/archive/2004/07/20/634.aspx in which he discussess his implementation of the Database rollback issue. MBUnit also is integrated with NunitAddin.
Mike, thanks for the info and links – it seems this issue has gained some pretty good momentum.
I recently got the “TDD with .NET” book by Newkirk and Vorontsov and they also have some pretty detailed information on how to setup your data access code tests.