Skip to content

The road to enlightenment

Thu Jun 24 2004

Earlier this year I started using NUnit to see what all the fuss was about. I started on a subset of an application that I'm working on, using it for the database interaction code. I figured that would be a good place to start, since I'm not sure how to test UI stuff, and these were the parts handed to me when the application was in spec stage.

I took a pretty simplistic (and probably wrong by some accounts) approach - set up a database with the same structure as what would be used in the end (appended with NUnit to separate the DBs) and make my assertions on the objects returned or modified there.

So, at the suggestion of someone who digs DataGrids, I picked up the TDD in MSFT.NET book by Newkirk &Vorontsov. I just barely cracked chapter 2 and came across something that I did not know and did not occur to me thru running my tests (with my apologies):

The function Init is marked with an attribute called [SetUp]. NUnit uses this attribute to ensure that this method is called prior to each test being run, which means that each test method gets a newly created Stack, instead of one modified from a previous test.

Seriously? I just figured that [SetUp] ran once, so all I did was initialize my connection string there. This book is already pretty good, if I'm able to learn something by chapter 2...I'm looking forward to finishing it :)

💾 May the source be with you. v3.2.419