26

It seems to me that everyone uses NUnit without even considering the other options. I think this is because:

  • Everyone is familiar with it already so they won't have to learn a new API.
  • It is already set up with their continuous integration server to work with NUnit.

Am I wrong about this?

I decided to use xUnit on one of my own projects recently and I love it! It makes so much more sense to me and conceptually it seems like a definite step forward from NUnit.

I'd like to hear opinions on which framework is actually the best - not taking into consideration having to learn it or reconfigure your automated testing.

5
  • 6
    Please define best. Cheapest? easiest to code? fewest lines of code per test? stackoverflow.com/questions/680298/… Feb 16, 2011 at 11:39
  • Sorry, I meant most powerful, stable and intuitive, whatever. I'm asking for opinions and reasons why. I left 'best' to the answerer's imagination because I would also like to see which of those aspects are important to people.
    – Nobody
    Feb 16, 2011 at 11:42
  • 2
    If you can reword your question then it might be OK, otherwise this is just a "list of X" question which aren't constructive. See six guidelines for constructive subjective questions
    – ChrisF
    Feb 16, 2011 at 12:02
  • 2
    "best" is a dumb thing to ask - because there is very rarely a single best partly because it will depend on context and partly because it is inevitably to some degree subjective.
    – Murph
    Feb 16, 2011 at 12:44
  • 10
    Murph. First, this site is for subjective questions. Second I'm asking for opinions so I'd like to see others' interpretation of 'best'. And don't call me dumb.
    – Nobody
    Feb 16, 2011 at 13:15

4 Answers 4

15

MSTest

I personally use MSTest. NUnit is really nice, but in VS2010, MSTest is already fully integrated into the IDE and there are full project templates for it. For .NET, if you're using 2010, then I think MSTest is the way to go (MSTest in VS2008 I don't think is up to par) simply for the code coverage, test runner and other tools that are available to you out of the box. (If you use CodeRush or R#, then they have really great test runners/tools for other testing frameworks)

Edit: I've since moved on to XUnit. :D

4
  • I voted up for both MbUnit/Galio and this answer. MbUnit/Galio is simply better, but their hands are tied when it comes to running MsTest tests, for some critical classes in that .Net library are final and not extendable. However, if you have to do GUI automation, then Coded UI and cuite.codeplex.com/documentation work on top of MsTest, so one just HAS to use them.
    – Job
    Dec 5, 2011 at 3:24
  • 2
    The issue I have with MSTest is that it does not natively support command line testing, this can be an issue when you want to run units via CI.
    – CmdrTallen
    Jan 20, 2014 at 14:20
  • 1
    Nunit is now fully integratable into VS right?
    – BenKoshy
    Mar 11, 2017 at 4:01
  • Yep, it is. Considering this is about 6 years old now, I've personally moved on to NUnit and then now to XUnit. Both (and others) have nuget packages that serve as adapters to light up the same VS functionality as MSTest. Honestly, MSTest is probably at the bottom of the list at this point. I would vote XUnit or NUnit. these days as both are solid, maintained, and modern.
    – Ryan Hayes
    Mar 13, 2017 at 18:29
14

I've started to use Gallio/MbUnit several years ago. And the features and gems it provides are just so powerful that I've never regretted my choice. In fact, I'm now part of the development team of the Gallio OSS project; so I can contribute to make it even more awesome.

  • MbUnit has many powerful features that just make my developer life easier (contract verifiers, test factories, structural equality comparer, combinatorial tests, data generation framework, text diffing, xml assertions, extension points, etc.)
  • Gallio provides a consistent platform to run all my tests with a nice reporting tooling. I'm also fond of the fact that I can integrate tests from other OSS projects which do not use MbUnit and just run them along. Seamless integration within many 3rd party tools is also convenient (R#, PoSh, dotCover, etc.) And the extensibility of the infrastructure is amazing (for example, I've just finished to write a test adapter for a native unmanaged C++ testing framework. It will be part of a future release soon)

The wiki is certainly a good starting point to discover Gallio and MbUnit v3. It sill misses some chapters but it's quiet useful already.

5
  • Structural equality comparer and data generation framework sound great. Can MbUnit do data-driven testing - i.e. read csv / xsd files and use them as test method arguments? That's one of the main attractions of xunit for me.
    – Nobody
    Feb 16, 2011 at 13:20
  • Sure. ASAIK MbUnit was the first testing framework for .NET to introduce data-driven testing. It can bind test paremeters to internal ([Row], [Column], etc.) and to external ([CsvData], [XmlData], etc.) data sources. More details here: gallio.org/wiki/doku.php?id=mbunit:data-driven_testing Feb 16, 2011 at 13:41
  • Have they fixed the performance problems they were having with Gallio and visual studio? Was the deal killer for us. Feb 16, 2011 at 17:00
  • I used MbUnit when I worked for a small company and it was great! I later used MsTest because I had to, and it worked out ok. I still prefer writing explicit code over configuring project settings. The corporate backing does help MSTest though. Whether the design is ugly or beautiful, you know that whatever comes out of MSFT will be well tested.
    – Job
    Dec 5, 2011 at 3:27
  • @YannTrevin What's the status of Gallio/MbUnit? I looked at the Google Code repository and it doesn't seem to have any recent changes. Is development happening somewhere else or is the project stalled? Jul 17, 2013 at 14:14
9

Picking one and using it is perhaps the most important step here.

Personally I would choose NUnit for a few reasons. First and foremost is tooling support. There is a free add-in for Visual Studio 2010, and all major 3rd party plugins support it. Every single build system, test coverage utility and CI server supports it. In many cases without a plugin. On the code level, it can handle just about any scenario at this point -- data driven tests, inheritance, abstract test classes, generic test classes, setup, tear down, etc. To some extent we have xUnit because NUnit got too feature rich and powerful.

Beyond NUnit, I think you could make a pretty decent argument for MBUnit + Gallio as mentioned by Yann -- it is a very solid framework. The one you should avoid if at all possible would be MSTest, which has a few fatal flaws IMHO. Flaws being some of the constraints on your test classes, such as no inheritance, and dependencies on professional or better visual studio SKUs. Including requiring visual studio be installed on the build server in order to run the tests.

0

The one reason is NUNIT become more industry standard than xUnit. But personally, i love xunit.

Not the answer you're looking for? Browse other questions tagged or ask your own question.