# Saturday, January 24, 2009
« Set per user environment variable in Ubu... | Main | Sticking WIth It »

Update: Resharper 4.5 beta is out, and it natively supports MsTest.

Update: I updated this plugin to work with ReSharper 4.5

Chances are, if you have ReSharper you're using the built in ReSharper test runner. The Resharper test runner is pretty frictionless assuming you're using one of the open source testing frameworks like NUnit.

If you're stuck using MSTest for some reason, like in my unfortunate case my company has standardized on it... then you're pretty much stuck using the MSTest runner, which really sucks for numerous reasons.

The MSTest runner likes to muck around with vsdmi and testconfig files (or something like that, I can't remember) and is pretty slow. Up until VS 2008 it was almost completely useless for TDD.

Its almost usable in VS 2008, but I still hate the test failure reports. I can't just scan a bunch of grouped tests to see which one's failed and why. To really see why, I have to open a new test report tab in VS. Even more annoyingly, MSTest refuses to find my resource satellite assemblies without additional hoop jumping. I like to call that friction.

After finally having enough of this I decided to create my own MSTest ReSharper 4 plugin (Apache 2.0 license). It was actually quite easy to hook into the ReSharper test infrastructure, especially since JetBrains gives you most of the code to do it in the form of a csUnit plugin. A few deletes and edits later, and I have a functional MSTest plugin.

image

Not only does it work, it works better. My satellite assemblies are found right out of the gate, reports are inline with the runner, and for a moment I almost lapse back into mistakingly typing NUnit attributes.

image

Now mind you, its not perfect, but it works really well for my needs. Some gotchas, or differences between the standard MSTest runner and my plugin:

  • TestContext is always null, the runner doesn't provide that. Unit tests shouldn't need it anyway.
  • AssemblyInitialize is not honored, much like like TestDriven.NET. I get around this using a static initializer in my base class test fixture (I need this for some slow integration tests if you're wondering).
  • MSTest seems to create a new test fixture instance between each test run, this plugin only creates a single instance of the fixture. Generally this shouldn't be a problem if your TestInitialize method is written correctly.

Binaries and source are available on my Google Code web site. To install, just drop the DLL into the ReSharper bin\plugins folder and restart VS 2008. Happy testing!

Tuesday, January 27, 2009 7:13:45 AM (GMT Standard Time, UTC+00:00)
Nice! Now, I know what to use if I ever do find myself in an MSTest only shop.
Monday, February 02, 2009 9:09:50 PM (GMT Standard Time, UTC+00:00)
I'm in an MSTest-only shop, by choice (devs new to Unit Testing, not to mention TDD, so we're keeping the entry barrier low--"right click, create tests"). But for me, this rocks, thanks!!
Saturday, March 07, 2009 1:16:30 AM (GMT Standard Time, UTC+00:00)
Thank you very much. It looks nice - I have just downloaded it and I will check it out.
Tuesday, March 17, 2009 10:44:06 AM (GMT Standard Time, UTC+00:00)
This is fantastic - easy to install and makes my life alot easier - thanks.
Wednesday, April 15, 2009 8:17:54 PM (GMT Standard Time, UTC+00:00)
Any plans to support R# 4.5? Even though it supports MSTest your plugin is much faster.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview