12

I need to work in a team to develop a mid scale Desktop application developed using C# .NET. Prior to this, I have not applied Unit Testing and Test Driven Development. I am aware that there exists many tools and framework for Unit Testing C# applications. As of now, I am aware of Nunit and the Unit Testing facility integrated with Visual Studio.

I would like to know, how do the two compare?

3 Answers 3

14

There is some overlap between the two for sure. NUnit is the predecessor, and as a result more mature. C# Unit Test framework is younger, but integrated with Visual Studio.

I've come from the Java world where JUnit is king (there are others, but none as popular), and NUnit 2.5.x is a really good match to the way JUnit 4 works. In fact, it works much better than the Java counterpart.

As far as test definition is concerned, I favor NUnit. Sure MS Test has similar (but different) attributes that you apply to your classes, but I believe it is lacking some features that can save you some work on some types of testing. You may want to check out a similar discussion on StackOverflow.

I like the new assertion model built in to NUnit (it is using the Hamcrest style asserts) because they are both easy to read and easily extensible.

  • NUnit will have better 3rd party support, MS Test will have better integration (out of the box).
  • NUnit will have better flexibility and extensibility, MS Test will suffer in this area.
  • Both run unit tests and check your results, both will work for TDD.
3

The only real difference I noticed when I had to create a build script to run on a dedicated MSBUILD server form TFS, setting nUnit up and getting nUnit test results was a real pain, setting it up and getting the results for MSTest was a breeze.

Also there was a problem with Resharper where MSTest test's couldn't be run from the test runner. In newer versions this is fixed, so if you have an old version of Resharper it still might be a problem.

This post from Roy Oshereve is still a nice overview.

p.s.: Deleted my other answer, wasn't helpful at all, my apologies for that one.

1

You might also want to have a look at Gallio/MbUnit which is mostly known for the numerous advanced features it provides. There is a nice tutorial on the Gallio wiki.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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