September 23, 2007
@ 10:39 AM

I would have to say that I have become a convert to TDD concepts. I have used NUnit, and mbUnit testing frameworks to varying degrees for some time. Now I use them daily and am working to increase my coverage in all my projects.

Since I primarily develop in the .NET Framework I have particular interest in the unit testing frameworks available in that environment. As I mentioned in a previous post I have currently settled on mbUnit as my unit testing framework.

xUnit is a new framework developed by, among others, James Newkirk and Brad Wilson. James was one of the original authors of NUnit and is now a Microsoft employee. Brad Wilson also works for Microsoft. Together they have created what looks to be a very well thought out testing framework.

xUnit is currently being hosted on CodePlex and is distributed under Microsofts Permissive License (The borgs version of Open Source).

The framework has already been integrated with TestDriven.NET, and has it's own console runner, but no GUI runner yet.

Roy Osherove has a series of posts about his view on xUnit, and both James and Brad have blogged about it as well. The first post of interest to me was this one, then check this one.

After reading all the various points of view on this topic here is what my take away is so far. xUnit is a conscious choice to re-invent a testing framework that is not just another port and extension of JUnit. It features design changes to bring it more in line with where the .NET Framework is, and is heading. Examples of this are the use of Generics and Anonymous Delegates in Asserts.

They have also removed a great number of what they consider extraneous attributes see the quote from James post below:

    • [TestFixture] was removed entirely, so tests can be anywhere.
    • [Ignore] is expressed using the Skip= parameter on [Test].
    • [SetUp] and [TearDown] are removed.
    • [ExpectedException] was replaced with Assert.Throws.
    • [TestFixtureSetup] and [TestFixtureTearDown] are instead expressed as implementations of an interface (ITestFixture).
    • Support for IDisposable was added for tests.

This kind of thinking and approach is long overdue in my own opinion. It will be interesting to watch as the project matures. I have begun playing with it myself and so far I find it a lot more intuitive than any of the JUnit derivatives I have used in the past.

While I like mbUnit I have always had to think harder than I feel I should in order to use it. I get results that are often exactly opposite what I was expecting, which means that I am obviously not understanding something. It is also difficult to get help with mbUnit, while it is not abandonware it does not have a very active community, posts to their list server often go unanswered for long periods of time. And the Google Group discussion forums are none to active either.

Time will tell if xUnit suffers from the same lack of community or not, but so far it looks promising! 

Cheers,

Robert Porter