• 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. :)

  • 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.

  • 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?

  • Roy,

    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)?

  • 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!


  • 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

  • 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.


  • 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.

  • 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.

Comments have been disabled for this content.