Introduction
If you have ever felt bored of wasting time opening Debug -> Attach of Visual Studio to attach to NUnit GUI application for debugging, then this macro is for you.
Background
No background is required.
Using the Code
First, download MsacroAttachNUnit.zip and extract the file Debug.vb inside this zip to your local drive.
Next, open Macros IDE by either going to menu Tools -> Macros -> Macros IDE or pressing Alt + F11.
After the IDE is open, in its Project Explorer Windows, right click on MyMacros and choose Add -> Add Existing Item. Then point the file browser to file Debug.vb.
Now, close the Macros IDE and open the Macros Explorer by either going to menu Tools -> Macros -> Macro Explorer or pressing Alt + F8. There is a macro named DebugNunit under MyMacros.Debug.
From now on, you can run the macro by double clicking on it in Macro Explorer to attach to NUnit GUI application. In order to make life a little bit easier, we can create a toolbar button for this macro. All the things you need to do is right click on your toolbar and choose Customize, then browse to command MyMacros.Debug.DebugNunit as in the figure shown below:
Drag the command to anywhere most suitable for you and forget about all macro things. Just click the button whenever you want to attach to NUnit GUI for debugging.
Points of Interest
There are no points of interest except trying to find some "solution" for your laziness:-).
History
- 5th July, 2008: Initial post
|
|
 |
 | Thank you! DrMcClelland | 8:08 2 Jul '09 |
|
 |
It works great for what we need!
|
|
|
|
 |
|
|
 |
 | Error HariPriya | 11:22 24 Apr '09 |
|
 |
I get "Invalid Index" msg, which location does the macro expects the nunit.exe to reside...
|
|
|
|
 |
|
 |
Hi, the macro only expects that at least an instance of NUnit-Gui to be running. The error message tells that there is no instance of NUnit-Gui is running, if there are more than one instances of NUnit-Gui then the first instance would be attached.
|
|
|
|
 |
 | Can't you just set debug to run NUnit? Member 2187678 | 17:45 8 Jul '08 |
|
 |
I always just run NUnit directly from Visual Studio. That means all I have to do is hit F5 and NUnit start running. In the Debug section of your test project set it to "Start external program", set the path to NUnit and put the assembly name as the command line.
I almost always debug my unit tests since it doesn't add that much overhead. Also, I like to single step through my unit tests so setting breakpoints and hitting F5 is exactly what I want to do.
|
|
|
|
 |
|
 |
Yes, I can start it directly in VS. However, it's not always the case. For example, I start Nunit first for testing my application which is started directly in VS. And to some point, I need to debug code inside my test. Then I used to attach to Nunit manually and really did not like that way.
And the interesting thing is project independent, I set this macro once then use it whenever needed rather than setting for each Nunit project.
We can also change the macro a bit to attach to other applications.
|
|
|
|
 |
|
|