NUnit vs. MsTest: NUnit wins for Unit Testing.

My blog has moved. You can view this post at the following address:
Published Friday, March 5, 2010 6:19 PM by RoyOsherove
Filed under:


Friday, March 5, 2010 7:20 PM by Jamie Cansdale

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

I've been working with MSTest a lot recently, adding support for the VS 2008 and 2010 flavours of MSTest to TestDriven.Net 3.0. There are some quirks and differences between the VS 2008 and VS 2010 versions that I've had to deal with.

1) This thing you mention about ExpectedException isn't actually a bug, it's more a badly named parameter. They've renamed it from 'message' to 'noExceptionMessage' in VS 2010. It's a message that will be displayed if no exception is thrown. For example:

[TestMethod, ExpectedException(typeof(ArgumentNullException),

  "CreateDomain shouldn't accept accept a null friendly name")]

public void CreateDomain_Null_ThrowsArgumentNullException()




2) The VS 2010 version of MSTest now supports test fixtures that inherit from an abstract base class (that contains tests).

3) You can force MSTest for VS 2010 to execute in a 64-bit process using a setting under 'Local.testsettings > Hosts'.

If you use MSTest much, you should find the MSTest support in TestDriven.Net 3.0 Beta 2 is fast and pretty comprehensive. It now even supports data driven tests. :)

Friday, March 5, 2010 7:35 PM by yaronn01

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

I love NUnit, but unless I missed something there is not test runner fully integrated in VS. Even the Resharper runner still does not support all of the new attributes.

Friday, March 5, 2010 8:04 PM by Ryan Rivest

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

Hi Roy,

I may have misunderstood you mean by abstract test fixture, but if I understand correctly, I have used them with MSTest.

MSTest does not allow you to decorate the abstract fixture with the TestClassAttribute, but if you have methods decorated with the TestMethodAttribute, those tests will be inherited by the derived fixture.  So for example, if you had 5 tests in the abstract fixture, when you run the tests in your derived fixture, it will execute those 5 abstract test methods additionally.

Does NUnit handle this scenario differently?

Saturday, March 6, 2010 3:23 AM by Vagif Abillov

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.


For many developers MsTest has one attractive feature that outweight its weakenesses: it's runner is built-in into Visual Studio. Recently I read in Ben Hall's book about testing ASP.NET applications that VS 2010 test runner can be used to execute NUnit test. If this is true, this can make a lot of people start switching to NUnit or at least make beginners choose NUnit. But was not able to find anything about this. Do you know if there are such changes in VS 2010 test runner so it can now be configured to run tests with NUnit syntax (I guess TestCases will still be a problem)?

Saturday, March 6, 2010 1:06 PM by svdeursen

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

Just like Ryan I use abstract base classes in MSTest. I'm interested what you exactly mean.

Here's an example of what I use with MSTest:

public abstract class IntegrationTestBase


   private TransactionScope scope;


   public void TestInitialize()


       scope = new TransactionScope();



   public void TestCleanup()






public class IntegrationTest : IntegrationTestBase



   public void TestThatRunsInTransactionScope()


       // This test runs in the context of the TransactionScope!




Saturday, March 6, 2010 3:26 PM by Euan Garden

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

I pointed out on stackoverflow that a bunch of your information is out of date as of 2010. Jamie has already pointed some of that out above

Monday, March 8, 2010 7:19 AM by Bjoern Rochel

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

Regarding the abstract classes for test fixtures:

There's a slightly different behavior in MSTest depending on where it's run (at least in the 2008 products and our machine). If they're run locally abstract base classes containing tests work as expected. However, those tests break when beeing run in TFS 2008 Team Builds.



Monday, March 8, 2010 9:46 AM by Igor Brejc

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

It's not just NUnit vs MsTest. I've been using MbUnit (a.k.a. Gallio) for several years now and I never looked back. Most of the features (both NUnit's and MsTest's) you mentioned were present in MbUnit for some time now. And much, much more.

Monday, March 8, 2010 11:56 AM by Joe Wilson

# re: NUnit vs. MsTest: NUnit wins for Unit Testing.

I prefer the more natural and fluent assert syntax in NUnit, like:

Assert.That(x, Is.EqualTo(1));

instead of:

Assert.AreEqual(1, x);

NUnit also has a lot wider assert API, which I think makes the tests much more readable when you come back to them 6 months later.