Joe White’s Blog

Life, .NET, and Cats

ReSharper, day 5: Integrated unit-test runner

Welcome to day 5 of my 31 Days of ReSharper, where I introduce you to ReSharper’s unit-test runner.

ReSharper unit test runner

(The ReSharper test runner is also available for free as a separate download, if you don’t want to buy the full-fledged ReSharper.)

Now, why would the world need another unit-test runner? There are already so many ways to run tests. There’s the NUnit GUI, and the NUnit console runner. You can (and I have) write a rakefile that builds your solution using MSBuild and then runs the NUnit console, set up a Tools menu option to invoke it, and bind a keystroke to it. You can install TestDriven.NET. (You could even pay a lot of money for Microsoft’s test runner, although it doesn’t actually let you run the tests.) Don’t these cover just about every possible option?

Well, yeah. But ReSharper’s test runner is shiny. And being an IDE add-in, it manages some nice integration. Let’s take a tour.

Running all the tests

I’ve ranted about this before, so let’s start with the number one most basic feature of a testing tool: running all the tests.

Yes, ReSharper can do it, and it’s easy. The best way to run all the tests is to bind a keystroke (we use Ctrl+Shift+T) to the ReSharperAddIn25.UnitTestRunner_RunAllSolution command. Then, any time you hit Ctrl+Shift+T, it will automatically build your solution and run all the tests, showing the green (or red) bar as it goes.

If you don’t want it to be that easy, you can also go to the ReSharper menu > Unit Testing > Run All Tests from Solution. There are a couple of other options in the Unit Testing menu, but I ignore them, as they look like they do something other than run all the tests — and so far, we’ve done pretty well at keeping our NUnit tests fast.

Supported test runners

Out of the box, ReSharper’s test runner supports NUnit and csUnit tests. There’s also a third-party add-in to add mbUnit support to ReSharper UnitRun.


The ReSharper test-runner add-in really takes full advantage of being right there in Visual Studio.

  • Dockable. The test-runner window is dockable just like all the other IDE windows, so you can tuck it out of the way. I dock it to the bottom of the IDE, in a tab-set with the Output window and the various Search Result windows. (If you put it in a tab set, and a different tab is visible when you run the tests, the test-runner window will come to the front, just like you’d want it to.)

  • Key-bindable. As I noted above, it’s terribly easy to bind a single keystroke to mean “build everything, then run all the tests, and show me the results with a red or green bar”. So easy.

  • Pays attention. When you make code changes and rebuild, all the icons in the tree turn into little question marks, so you can see that you haven’t run the tests yet. But they keep their colors, so you can still see which ones passed and failed last time around. Here are screenshots of the “freshly run” (check marks) and “after rebuild” (question marks):

    ReSharper unit test runner, showing check marks and error icons for each testReSharper unit test runner, showing question marks after building and before re-running tests

    It’s even smart enough that, if you build your solution, but you haven’t actually modified any code, it won’t switch to the question marks. (I love this, because I’m always getting distracted by a conversation or something, and then can’t remember whether I just ran the tests or not.)

  • Jump to the code. Two nice features here. First, if you double-click on a test in the test tree, the editor shows the code for that test. Secondly, if tests fail, the test results pane puts hyperlinks into the call stack, and clicking one of those hyperlinks will jump to that location in the editor.

    ReSharper unit test runner, showing a test failure message and hyperlinked call stack

  • Gutter icons to run or debug a test. Wherever ReSharper notices a test method, it will show a little green-and-yellow circle in the gutter next to the code. If you click on that circle, you’ll get a dropdown menu with, among other things, an option to run that one test under the debugger. So if you want to put a breakpoint in a test and debug just that test, it’s easy.

    ReSharper gutter icons for running unit tests

Nothing in the ReSharper unit test runner is really groundbreaking, although the “jump to the code” features are pretty nice. It’s just that the features are all there, and they’re done well. If you do unit testing, give their test runner a try.

There are no responses to “ReSharper, day 5: Integrated unit-test runner” yet.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Joe White's Blog copyright © 2004-2011. Portions of the site layout use Yahoo! YUI Reset, Fonts, and Grids.
Proudly powered by WordPress. Entries (RSS) and Comments (RSS). Privacy policy