Search The Blog
My Books

New:

My Songs

 

The Art of Unit Testing

Buy PDF or Print book at Manning

Buy on Amazon

Latest Posts
from 5whys.com
Twitter: @RoyOsherove
About this site

TDD in .NET Online Course

TDD and BDD in Ruby Online Course

 

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

« Introducing Typemock Test Lint | Main | Solution: Visual Studio 2010 beta 2 extension does not load in vs 2010 RC »
Friday
Mar052010

NUnit vs. MsTest: NUnit wins for Unit Testing.

People are still wondering what are the differences between the two most popular unit testing frameworks in the .NET world: the open source NUnit and the commercial MsTest).

Here’s a short list of what i remember instantly:

  • Nunit contains a [TestCase] attribute that allows implementing parametrized tests. this does not exist in msTest
  • MsTest's ExpectedException attribute has a bug where the expected message is never really asserted even if it's wrong - the test will pass.
  • Nunit has an Assert.Throws API to allow testing an exception on a specific line of code instead of the whole method (you can easily implement this one yourself though)
  • Nunit contains a fluent version of Assert api (as already mentioned - Assert.That..)
  • Nunit is much faster
  • NUnit can run tests in 32 and 64 bit (MSTest only runs them in 32 bit IIRC)
  • NUnit allows abstract classes to be test fixtures (so you can inherit test fixtures). MsTest does not.
  • NUnit allows non public classes to be test fixtures (as of the latest version)
  • NUnit was created SOLELY for the idea of unit testing. MsTest was created for Testing - and also a bit of unit testing.
  • NUnit contains PNunit (running prallel tests with Nunit). MsTest only adds this ability in vs 2010

given all these – MsTest has much better abilities for integration based testing (all these are things Nunit doesn’t even want to have):

  • ability to do data-driven tests from a db data source
  • ability to do performance testing
  • ability to determine the order of tests (ordered tests)
  • ability to easily setup and teardown and generate database data
  • great integration with team system reporting for LOADS of statistics

having said all these:

if you’re working with team system, I’d use MsTest. the integration with other team system tools and reporting is just beyond compare and the reporting alone helps alot to find recurring breaking tests, code churn vs. new tests and others.

PrintView Printer Friendly Version

Reader Comments (5)

Does NUnit have a similarity to private accessors? This means that the testing framework creates a class that accesses a class' private properties and methods. Or does not NUnit like such a construct? ;)

January 3, 2011 | Unregistered Commenter_JERKER_

"the reporting alone helps alot to find recurring breaking tests, code churn vs. new tests and others"

How?

Would the nUnit reports to MSTest reports xslt accomplish this too?

February 9, 2011 | Unregistered CommenterRobb Schiefer

This seems like a great article, except now a year later many of these points are false and I wonder how accurate they were back then as well. VS2010 does support 64 bit testing for one. There also seems to be an unbalanced coverage of what you are presenting. Your facts do not support the Versus argument completely. Not to mention either you or the stack overflow poster seems to have plagiarized the points for both sides.

March 15, 2011 | Unregistered CommenterBryan Wood

bryan: ya - i'm all about the stack overflow points - seen how many i have?
also - the fact that it takes several years for vs, and two releases, to come CLOSE to what nunit had two years ago - you really are fighting in favor of that?

fyi - mstest bugs in excpetion still exists. and it still does not support assert.throws or parametrized tests (testcase in nunit).
it's fucking march of 2011 as i write this -and that is all there is to say on that.
kthxby

Roy.

March 17, 2011 | Registered CommenterRoy Osherove

I actually prefer xUnit.net over MSTest, but here's another list of MSTest shortcomings.

March 17, 2011 | Unregistered CommenterMark Seemann

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Web Analytics