TeamAgile's DataRollback attribute upgraded to VS.2005, .NET 2.0 and NUnit 2.2.8

Posted by Kyle Heon Mon, 17 Dec 2007 01:22:00 GMT

I’m currently knee deep with a complete rewrite for one of our large e-commerce sites in .NET 2.0. Part of this rewrite has us finally getting unit tests into the solution.

For the past week I have been working on trying to get a framework in place that allows us to load suitable test data into the testing db for proper unit testing. For this system it is necessary due to all the intricate relationships between products, styles, skus, orders, order line items, etc.

I have been working on a framework similar to what Rails TDD offers, where you specify the fixtures required but continue to run into a strange issue that causes the code to run multiple times for each fixture, even though there is only one test in the fixture.

In an effort to get something in place for this week I began exploring what Team Agile (found via/from Roy Osherove’s ISerializable blog). This has been coined XtUnit.

Even though I met the min requirements of having COM+ 1.5 support (Windows XP SP2 OR Windows 2003) I was not able to get things to work. At first it turned out that I wasn’t sub-classing ExtensibleFixture but then it didn’t like the version of NUnit I had.

As it turns out the source was provided using VS.2003, compiled against NUnit 2.2.1 (2.2.x for sure, believe it was 2.2.1). I’m using NUnit 2.2.8 at this point so I not only upgraded the solution to VS.2005 but also recompiled using NUnit 2.2.8 and so far I think things are working quite well. The DataRollback attribute is working perfectly.

This will work for now in that it at least ensures that tests are atomic, not affecting other tests. It does not however help me ensure that we have appropriate test data in the system. That currently is handled via a nant script that clones the db structure from our dev db into a new local test db and then a data.sql that is run to load initial lookup data.

To make it easier for anyone struggling with the same issues I am providing the upgraded source as well as recompiled binaries for download. You can get them below.

If anyone can explain to me why when adding an attribute at the class level would cause this code to be executed multiple times (with just one test in the test fixture) I would love to hear about it in the comments.

Posted in  | Tags , , , ,  | 2 comments | no trackbacks