Geeks With Blogs
Greg Young Greg.ToString()

Just listenned to the latest dotnetrocks with Ted Neward as the guest.

Really interesting discussion on TDD .. don't necesarily agree with alot of it but very interesting points brought up.

At one point they were discussing http://www.ambysoft.com/books/refactoringDatabases.html. They discuss “unit testing” databases, in particular writing unit tests for the data model. I believe this is the wrong term; one should be writing integration tests for the data model. Alot of people have been discussing these differences of late as the concept is often confused.

So let's look at how domain driven design can help us with integration testing of our database ...

As I discussed in a previous post the repository pattern acts to abstract our data source from our domain. We generally create our repositories as an abstract contract within our domain. During periods of development we use an in memory representation of a repository in order to perform our unit tests as we want our unit tests to be very fast. Since we have unit tests written for the abstract contracts of the repositories we can re-use these tests when it becomes time to integrate with our database. We should in fact be able to completely test our integration with a given database simply by running our normal repository unit tests against the repositories that integrate to the database.

Although these tests can be slow they allow us a tool that we can use when it becomes time to refactor our database and/or or mapping to the database as opposed to relying upon testing of the application. This is key as there are often multiple applications hitting the same database, too often we end up in the case where we make a change and test an application only to release the change and find out it broke another application. By taking a domain first approach and sharing the domain code between the applications we have given ourselves a testable interface to our data.

  Posted on Friday, May 12, 2006 1:56 AM | Back to top


Comments on this post: DotNetRocks - Ted Neward

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Greg Young | Powered by: GeeksWithBlogs.net