Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 14 down vote accepted

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.
share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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