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.