MSTest and nUnit quick pros and cons

Posted: 2010-02-09 in Code and Computers

I was curious about how nUnit compared to MsTest on paper.

So I composed a quick list of stuff found on the net and ran a quick project in both…

Cons Versus Pros
MSTest nUnit
No standalone test package, needs to install Visual Studio on the Continous Intergration server Standalone, easy to include in source control for new developers to be un and running instantly.
Is tricky to integrate with CC or Hudson CI servers Easy integration into 3rd party vendors like CI
Built into Visual Studio (limited edition), extremely good VS integration The Resharper UI plugin is almost a must with nUnit UI, there is a stand alone UI but it has not VS integration
29 assertions 42 assertions
20 attributes 15 attributes
Large Company Support and with the MSDN subscription could be quiet cheap Open source with currently very good support BUT! could die a slow death in a few years
Slower release updates due to .Net and VS tie in’s Currently Rapid response to bugs and stead stream of updates
Slow test start up time, but the test themselves seem to run ok Very quick to run Test and Multiple Test which is great for the developer
If you have Team Foundation server you can link work items or bugs to failing task No “red thread” but with Hudson and a magnitude of other applications having easy nUnit plugin support, it isn’t a real problem.
AutoGenerate unit test and wit the Pex plugin paramter checking, does spam a lot of files and you do lose some control here No Auto generation but not sure this is a problem anyway as its very simple to get started.

Also it can be noted that if you are using the basic unit testing framework then you can almost run both… almost in the sense that it is easy to go from

MsTest to nUnit due to its asserts limitation but hard to go back again.
//region configure using nUnit as the base
#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using TestContext = System.String;
using DeploymentItem = NUnit.Framework.DescriptionAttribute;

For me I found nUnit, for our setup, was the better way to go, even on paper and in real life… well 2 years later and still I think its winning.
But I do though recommend the Resharper plugin and a good look at a mocking framework like rhino mocks to help complĂ­ment the two.


  1. Fredrik says:

    I largely agree with your analysis, even though I think that the TestDriven.NET addin for Visual Studio frankly kicks ReSharper’s butt. I just love the context menu options that is never further away than a mouse click. Especially, “Repeat Test Run” which will run the exact same test (or tests) as last run, from anywhere in the code. Highly efficient when fixing bugs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s