# Saturday, January 24, 2009

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!

Saturday, January 24, 2009 2:29:37 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [5]  | 
# Tuesday, January 13, 2009
Because I keep forgetting, and writing is supposed to help you remember things...

./etc$ sudo gedit environment

Tuesday, January 13, 2009 2:16:19 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  |