Category Archives: visual-studio

NUnit 3 and the GUI Runner

NUnit has been my favorite unit test framework for years.  I find it has the features that work best for me.

I recently upgraded to NUnit 3.2.  The latest version of NUnit can be downloaded from here.

NUnit GUI Runner
NUnit GUI Runner

NUnit has always had several methods to run the tests you write.  Probably the most popular way to run the tests, at least as a developer in the middle of working on a particular feature, has been the GUI runner.  It provides a quick visual mechanism of seeing which of your tests have failed and the reasons why.  After installing NUnit 3.2 I went looking for the GUI Runner but couldn’t find it.  After a bit more digging I found a post by the developers indicating that they had split the GUI runner development from the framework development and that the GUI was still months away from completion.

In short, the “official” way to run unit tests now in NUnit 3 is to use various test runners.  Until the GUI Runner makes a comeback, we’re going to configure Visual Studio’s test runner to run our tests.  It’s pretty easy.

Test Explorer
Test Explorer

Open Visual Studio (I’m not going to go into how to use NUnit in this post. NUnit has some really great and easy to follow documentation.)  No need to open or create a project.  Click on the Tools menu, then Extensions and Updates.  Select “Online” then in the search bar type “NUnit Test Adapter”.  Make sure you pick the NUnit3 Test Adapter.  Click on it then install.  You will likely be asked to restart Visual Studio.

Now when you run your test project you can open the Test Explorer (Test Menu, Windows, Test Explorer).  If you haven’t built your test project lately do so now.  Once you’ve built your test project you will see all of your tests listed in the Test Explorer.  With the “Group By” drop down in the upper left corner of the Test Explorer window you can change how your tests are grouped.  Setting it to “Class” will group your tests similarly to the default grouping in the NUnit GUI Runner, grouping them by the class the tests are contained in.  You can also right-click in the Test Explorer window to change the grouping option.

You will notice that the tests are not grouped like they are in the NUnit GUI Runner.  There are ways of doing it in Visual Studio Test Explorer, but I won’t cover that here.  Without the grouping it can be a bit difficult to run a subset of your tests, useful if you are working on a particular feature and just want to run the tests applicable to that feature.  A nice feature of the Visual Studio Test integration that partially solves this problem is the ability to run your tests by scope.  You can right click within a function, within a class our outside of a class.  This will provide the option to “Run Tests” in the context menu.  Clicking this will run all tests in the clicked scope.  It will run the single test function, all tests in the selected class or all tests in the namespace, respectively.

Test Icons
Test Icons

Another nice feature of the test runner is the visual cues on your tests.  In the image to the right you can see the 3 versions of the icons representing an un-run test, a successful test and a failed test.  Clicking on any of the icons lets you run the test directly and even debug the code without starting the whole project.

UPDATE: There has been some progress on the GUI Runner though you have to download the code and run it yourself if you want to use it.  It is on the NUnit Github site here.

Don’t Hide the GitExtension VS Toolbar

Monday mornings are rough.  It’s always hard to drag yourself into work after a few days away.  But at least the sun was shining and the birds were singing.

Unfortunately my idealistic Monday morning was rudely interrupted by Visual Studio giving me this lovely dialog:


“Ok, no problem”, I thought to myself.  “I’ll just restart Visual Studio”.  A few hiccups once in a while is not unusual.  However after my 4th restart attempt including a reboot in the middle and still getting the error I was getting worried.  Was I looking at a long day of repairing/reinstalling Visual Studio?

I figured I’d do a quick search online, though I couldn’t imagine I would find anything useful under “Visual Studio Crash Startup”.  I was wrong.

The offending little scamp

I came across several mentions of GitExtensions causing problems.  Specifically the GitExtensions Toolbar within Visual Studio.  Apparently it REALLY doesn’t like being hidden.  Fortunately I had already had my coffee this Monday morning and the gears were turning in my head (had this happened just one hour earlier we may have had a very different outcome).  I remembered that on Friday I had done exactly this, I had hidden the GitExtensions Toolbar in Visual Studio.  I love Git and use it extensively for my personal and professional side projects.  But this VM I am running on is used only for my day job and we don’t use Git.  So I had figured I would clean up my environment a bit.  Little did I know the tripwire I had just hit.

Apparently this is a known issue in GitExtensions (has been fixed as of 2.48.04):

There are a couple of ways to fix this issue:

1. Start Visual Studio in safe mode and unhide the toolbar.  You can do this by starting Visual Studio from the command line with the appropriate command line arguments:

DevEnv.exe /safemode

2. Use Control/Panel – Programs and Features to change your Git Extensions installation and remove the Visual Studio plugin (this is what I did).


3. Update to the latest version of Git Extensions.  This issue has been resolved.