Debugging a R# unit test runner

Debugging a R# test runner is, thankfully, not an experience most people will have to go through.

Because ReSharper runs unit tests in a separate process, spun up on demand, you need to find some way to attach to this process.

The brute force approach is simply to throw an exception somewhere in your plugin, and then attach.

A better alternative is to launch VS in ReSharper.Internal mode (or “god mode”, as some like to refer to it) by supplying the /ReSharper.Internal argument to devenv.exe. (You can also enable a specific plugin by using /ReSharper.Plugin “MyPlugin.dll”, which spares some of the pain when trying to build a plugin that is in use).

This provides you with some extra options. The one you want is “Enable Debug (Internal)” which can be found in ReSharper->Options->Tools->Unit Testing:

Once this is enabled, when you run a test a dialog will appear:

Giving you time to attach to the test runner:


2 thoughts on “Debugging a R# unit test runner

  1. Igal Tabachnik (@hmemcpy) October 5, 2011 / 9:18 pm

    Hey, I saw your blog through the pingback to my site.

    Nice trick, I didn’t know it existed. This was probably added in version 6.
    If ReSharper didn’t have that, you could also have attached to the unit test runner process by using Image File Execution Options. I wrote about it in my blog too, here.

  2. grahamrhay October 5, 2011 / 10:08 pm

    It’s been there for a while (since 4.5 at least, I think). I can’t claim the credit for finding it though, Jeff Brown introduced me to it.

    I like the look of the Image File Execution Options, I could have done with that a few times!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s