Tuesday, January 3rd, 2006 - 4:46 PM

Unit Testing in .NET

I’m doing some .Net (specifically C#) coding these days, and I need to unit test.

NUnitNUnit seems to be the most common solution, and definitely looks promising.

NUnit has a stand-alone GUI and a command-line mode, and although that’s sufficient, it doesn’t appear to integrate with Visual Studio 2003 like JUnit integrates with Eclipse, so I’ve decided to look around a little more.

csUnit – Another option is csUnit. It didn’t take me long to decide against csUnit. In fact, it made me want to rant. I have to confess up-front, it was an emotional response. I’m only *assuming* that their solution is inferior.

I didn’t make it far through their FAQ because it evades the questions rather than answering them. For example:

How does csUnit compare to XYZ? How is csUnit better than XYZ? (XYZ being a different tool)

The answer?

csUnit and XYZ offer different sets of features. Depending on your requirements and based upon your selection criteria, csUnit or XYZ may be the better fit. It is your decision! (blah blah blah)

Right… they’re “different”… I’ve heard of that happening, and they’re saying that I may want to use those “differences” as “criteria” to make my decision… but they’re not going to help me AT ALL in identifying the differences. Gotcha. They go on, using way too many commas, to explain that their “ethics and morale” make it undesirable to provide any sort of comparative analysis. Fine. OK, you csUnit guys go off and do your thing. I’ll go where the information is.

I wonder if csUnit was a school project that hasn’t been abandoned yet. It doesn’t seem to have an underlying philosophy that makes it different than other solutions — just an assertion of differentNESS.

So, what’s next on the list?

Visual Studio 2005 – It looks like Microsoft has added integrated unit testing into Visual Studio 2005 (and they seem to be claiming that they’re the first ones to offer unit testing integrated with the development environment — whatever). Unfortunately, this isn’t a good time for me to upgrade.

I’m not seeing anything else prominent, so it’s NUnit (for now at least). From what I can tell, switching from NUnit to Microsoft’s solution won’t be a major undertaking.

January 8, 2006 Update: Zanebug claims to be an NUnit-compatible solution with VS2003 integration. Like NUnit, it is open source. I will probably be using Zanebug instead of NUnit.

January 9, 2006 Update: I installed and fiddled with Zanebug, and although it ALMOST worked, I never succeeded in getting valid test results.

Rather than spending more than a short amount of time troubleshooting the default install with a very simple set of tests, I switched back to NUnit (which works just fine, although it doesn’t have IDE integration).

IDE integration is a nice idea, but actually working (without wasting my time) is much more important. I will probably not give anything else a chance until I switch to Visual Studio 2005.

2 Comments to “Unit Testing in .NET”

  1. Manfred Lange Says:

    Well, csUnit is NOT a school project. And no, I don’t think that we have to provide comparisons, but that we can tell you about what is good about csUnit. And we are more than happy to learn more about the things you would like to see in unit testing tools (or csUnit in particular). A brief history: csUnit was started in 2001 and was developed and used in commercial projects since then. And I’m a little surprised that you “assume” certain qualities about csUnit, and that you base several statements on your “assumptions”. Your post doesn’t indicate that you actually download it, tried it and then make your statements on facts. I can live with facts. Assumptions are just rumors at best. What do you think? — Kind regards, Manfred. (csUnit co-author, XP practitioner since 1999, agile leader since 2001, successfully introduced XP to 200+ engineers organizations)

  2. Woody Thrower Says:

    You definitely do not have to provide comparisons. I certainly didn’t mean to imply that you do. I think second-party and third-party comparison are important parts of deciding which options deserve a first-hand evaluation, and I believe the growth of csUnit is ill-served by refusing to make comparisons.

    Many inferior software products are created by programmers who just want to build their own. It is impractical to download and try each one. Especially when one option is so widely used that it’s practically an industry standard. An unknown package that refuses to differentiate itself is easy to write off. It doesn’t make business sense to evaluate it.

    I do not understand your refusal to compare on moral grounds. Comparison does not require that you make value judgements — you can simply list differences. For example, if I were to compare two flatbed scanners, I might mention that one is bulkier, while the other is USB-powered. The bulkier one might have greater depth of field, but be more expensive. Maybe the small one can stand upright, so it occupies less desk space. I can make those comparison without making any statement about which scanner is better, because neither scanner is “better.” Their differences accomodate different environments, budgets, and uses.

    If you truly have a moral problem with attempting to objectively differentiate, I’m curious how you’ve reached that position.

    Regarding me basing statements on assumptions: I did not make any statements about csUnit. I expressed some harsh opinions about the web site and the impression it gave me. I stand by those opinions (although I no longer wonder if csUnit was a school project), but csUnit itself remains an almost complete mystery to me.

    Thanks for taking the time to bring up your concerns. I hope I’ve clarified my position.

Leave a Reply