Unit Testing, Agile Development, Leadership & .NET - By Roy Osherove
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:
"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.
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?
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)?
Well, actually I received an answer to my question from Microsoft: social.msdn.microsoft.com/.../92da13df-0c4f-4212-be3b-cf1a9795a6ac
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!
Roy Osherove listed advantages of NUnit over MsTest but also mentioned one MsTest’s strength that can
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:
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.
In response to yaronn01:
"ReSharper 5 introduces a completely new approach to running your NUnit tests. Our engine is now based on native NUnit code. What it means to you is 100% compatibility with the latest released version of NUnit and full support of its recent unit testing features."
Pingback from Markus Tamm » Blog Archive » Links 09.03.2010
Stop the war between NUnit and MSTest : Make them friends
Why not using both?
I like the Assert API from NUnit, but I like the test report and easy automated build setup from TFS...
using Assert = NUnit.Framework.Assert;
see my blog for full article : alsagile.com/.../stop-the-war-between-nunit-and-mstest-make-them.aspx
Pingback from To work in .net using any of Asp.net,Vb.net,C# on Windows based … | C# WebDev Insider