NOTE: This post appeared on my old weblog.
I went to the local SQL Server User Group meeting today (they don’t seem to have a functional website at the moment). They had a demo of the new functionality in SQL 2005 (mostly from a DBA standpoint, which sometimes I pretend to be).
One cool thought that occurred to me – instead of using mock objects, perhaps you could just take a snapshot, do our tests, and then rollback the snapshot onto the database instance. It could be good for integration testing, but it might not work so well for unit testing, unless you are the only one using the database instance.
Regardless, snapshots are cool. The ability to mark a point in time, and then at some future point revert back to it, without having to do a full database backup has a lot of potential in terms of testing.
New Content:
After seeing Darrell Norton's presentation at Mid-Atlantic Code Camp, this idea seems like it might have a bit of merit. There are probably cases where it would work better than rebuilding the database at the start of running your unit tests. It all depends upon what you are testing. I'm going to have to try it out now.