Skip to content
Mar 6 2008

Thoughts on xUnit.net

When I originally started writing this post, it was of the scathing variety. A classic in your face, piss you off, flame war bait type of post. But I happened to be chatting with James tonight and he calmed me down a bit, so this post no longer has the furious anger of its original form, which of course is for the best. Sigh…

Anyway, recently I came to look at xUnit.net, another unit testing framework being driven by Brad Wilson and James Newkirk, and I have to say I’m not that impressed. There’s a couple things I like, such as Assert.Throws and using a constructor/dispose for setup and teardown, but I think the rest of it is questionable at best.

For example, instead of a [Test] attribute it has [Fact]. Um, yea. I applaud the BDD-style effort, but [Fact] is dumb. Call it what it is: a test. And think of it this way. If a test is actually an invalid test, for whatever reason, how can it be a fact? So you’d have an invalid fact? And when you run a fact and it fails you’d have a failing fact? Hmmm, I don’t think so. But I certainly could have an invalid test and a failing test.

And why did [Property] get replaced with [Trait]? Better yet, why is [Theory] used for data-driven tests? What was wrong with MbUnit’s [Row] and [RowTest]? I mean, come on, [Theory]? Really? Did you revert back to computer science classes just for the heck of it?

I also have issues with xUnit.net’s assertions. For the most part, all they did was remove the “Are” or “Is” prefix from the method names. So instead of AreEqual() it has Equal() and instead of IsNull() it has Null(). Wow, earth shattering. Yet xUnit.net has IsNotType(), which is equivalent to IsNotInstanceOfType(). Like I said, questionable at best.

However, the biggest problem I have with xUnit.net is that in a time when many of us are trying to get more developers to actually *do* unit testing, it comes along and creates a larger barrier to entry.

I say this because we already have 3 well established unit testing frameworks in .NET land: NUnit, MbUnit, and MSTest. All of them have been around awhile now, with NUnit being the granddaddy of them all, each with their strengths and weaknesses (although some/most will argue that MSTest only has weaknesses). If a developer asks you how to get started with unit testing, where will you point them? The quickest way for that developer to “get it” is to see it in action. Are you seriously going to tell that person to start with xUnit.net, and then answer their question about why a test is called a fact? I doubt it.

The other thing that bothers me about xUnit.net is that it was created by two guys who work at the company that owns MSTest, Microsoft. I wonder why they couldn’t pour this effort into making MSTest better? Is it because MSTest is baked into VSTS and can’t move fast enough? Is MSTest not extensible enough for their liking? Maybe there’s other internal issues that prevented them from doing that, but it seems odd nonetheless.

I don’t mind someone creating Yet Another Framework so long as it adds value to the developer community, and right now, I don’t think xUnit.net adds much value at all.

Similar Posts:

  • http://keithelder.net/blog/ Keith Elder

    I read your post, but um, I’m a little confused as to how you *really* feel about xUnit. What is it you don’t like?

  • Patrick (P-dizzle)

    Hey Dave, I was talking to Chad just yesterday and he mentioned xUnit.

    There’s something I think a little deeper behind all of this. Its no secret developers love religious wars, however there’s still a HUGE population of working “professional” developers out there who:

    1. Still don’t use source control at their companies (nor have the desire to set one up)
    2. Don’t use bug tracking
    3. Don’t use automated unit testing (forget TDD, they don’t test their code at all..just toss it over to QA)
    4. Automated builds? Well, the F5 key on Visual Studio..
    5. Read Tech Blogs (or MSDN articles, or anything beyond a search for a specific technical problem they’re at the moment having)

    In short, what is the end result of the fighting? Whether its NUnit, MbUnit, xUnit, MSTest its the same 20% (or less) of the developer population talking to itself.

    Just me thinking out loud, xUnit probably doesn’t add much to the developer community, simply because 80% of the developers aren’t EVER going to use automated testing anyway.

  • http://www.taumuon.co.uk Gary Evans

    I’ve written a blog post (a while ago), on what theories may give you above POUT. Let me know if it’s interesting.

    taumuon-jabuka.blogspot.com/…/comparing-theor

    Thanks,

    gary