Wednesday, November 14, 2007 9:32 AM
I had a lot of great questions during
last night's talk on different aspects of test-driven development. For the benefit of those who asked the questions (if they happen to be reading) as well as for the benefit of others, I've decided to provide a little more information here for reference...
- Rollback databases with unit tests
- There was a great question on how to best keep your database from becoming polluted with test data if your unit tests are actually touching your database. I recommended looking into either MbUnit's RollBack attribute or Roy Osherove's XtUnit. Both of these features allow you to encapsulate a unit test in a transaction which will rollback all changes to the database immediately following the test. This is a nice, simple way to keep your database clean between tests. Here's where to find more information...
- Continuous Integration and CruiseControl.NET
- We also had another great question on what the next step would be after your team was comfortable with unit testing and TDD. Although I'm sure this is debatable, my suggestion was Continuous Integration (CI) using CruiseControl.NET. This will allow you ensure that your tests are run regularly and will keep your code from becoming stale. This is also a great impetus to keep your tests running fast. A full discussion of what CI encompasses is definitely beyond the scope of this post but the short of it is that your build machine checks out all of the code, builds it, and runs all of your unit tests each time a developer makes a check in. Think of nightly builds, only instead of nightly they happen every time a change is made to the codebase. For a minimal cost (the software is free and the setup time though not negligible is minimal) you can do wonders for your teams velocity and integration testing. Here's where to find more information...
I hope helps to clear some things up. As always, if you have any questions don't hesitate to ask!