views:

140

answers:

3

I'm about to start a new C# application, which will probably take some while (read: > 1 year). I want to keep it cross-platform, that is, it should work using Mono, but my primary development platform is Visual Studio.

Now I'm looking into the test frameworks, but I wonder which one you would take for both being portable and reliable in the future. Right now, nUnit seems to be the standard, but given xUnit.net, I wonder whether this would be better as it seems to be more actively developed. Or should I stick with MSTest only? After all, I can expect MSTest to be supported for several years. For Java, it would be rather clearly JUnit, as it is supported everywhere, but the .NET landscape seems to be much more fragmented.

So the main question is not features etc. (MSTest is not too stellar in that direction anyway), but rather long-term reliability. In this light, which unit testing framework can you recommend?

+3  A: 

MSTest isn't, of course, portable, and it's tied to Visual Studio. If you're targeting Mono then ideally your tests should also run on Mono. Mono itself uses nUnit, or rather nUnitLite - so that may well influence your decision. Adding TestDriven.Net or Resharper to your toolset allows you to run nUnit easily within VS - but they aren't free if that's a problem you can try NUnitit

blowdart
+1  A: 

I guess you are looking for subjective answers. I like NUnit. Stability on the "interface" have not created any problems for me. It works well with any IDE and it is integrated with many build tools. Also if you know JUnit, you'll find NUnit very natural.

Willem
+1  A: 

NUnit really is supported everywhere. Our (200+ developer) shop just moved away from MSTest to NUnit and so far we've not encountered issues with lack of tool support: in fact, rather the opposite, it seems that the support infrastructure around NUnit is very extensive. This goes for continuous integration systems such as Hudson and Cruise Control.

We're finding that the development of NUnit continues to be very active. Version 2.5 includes features like

Assert.Throws
which have been taken from XUnit, but preserves backwards compatibility with tests that use
[ExpectedException]

MSTest lacks many of these features. Some, such as

[TestCase]
are very useful in the open-source frameworks: they aren't just "fluff" but reduce the amount of testing code you need to write and debug.

Just about the main positive aspect of MSTest is the tight integration with Team Foundation Server. This lets you link unit tests with bugs reports and build numbers: a handy feature if you're disciplined enough to use it.

Jeremy McGee