Ben Scheirman hates MSTest too!

I’m not the only one!

http://feeds.feedburner.com/~r/flux88/~3/141244484/DearVSTSTestIHateYou.aspx

Ben, since MSTest‘s functionality dwarfs that of NUnit’s I’ve found it relatively easy to have most of my tests run in both MSTest and NUnit. Of course, where I used NUnit’s more advanced functionality, I just disable the test in MSTest. Yes, its kind of a hack, but it works.

Each of my test files have using statement sections like this:

#if NUNIT
using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
using TestMethodAttribute = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using NUnit.Framework;
#else
using TestFixtureAttribute = Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
using TestAttribute = Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif

 

Then I maintain two project files. One is a MSTest project, and only opens in Team System edition. The other is a standard Class Library project – the typical NUnit test project. The later defines NUNIT in its project settings. By using type aliases like this, I can use either NUnit or MSTest attributes in my test fixtures. Of course any tests using NUnits Constraint Model Assertions won’t work in MSTest so I’ll either #if def out those tests, or I won’t include the entire fixture in the MSTest project.

1 thought on “Ben Scheirman hates MSTest too!”

  1. I’ve been using TestDriven.NET to run the tests for the most part which is good, but the problems I keep having with MS Test just piss me off.

    When the ReSharper Test Runner comes out for MS Test I’ll be a bit happier.

Comments are closed.