Skip to content

Instantly share code, notes, and snippets.

@andreav
Last active December 10, 2015 22:18
Show Gist options
  • Save andreav/4500523 to your computer and use it in GitHub Desktop.
Save andreav/4500523 to your computer and use it in GitHub Desktop.
Add external tool in Visual Studio to automatically launch NUnit on the current file
== LAUNCH NUnit FROM VS2012 ===========================================
TOOLS -> External Tool -> Add
Title: NUnit
Command: C:\path\to\nunit.exe
Arguments: $(TargetName)$(TargetExt)
Initial Directory: $(ProjectDir)\bin\Debug
TOOLS -> External Tool -> Add
Title: NUnit-console
Command: C:\path\to\nunit-console.exe
Arguments: $(TargetName)$(TargetExt) /wait /xml=nunit-test-result.xml /labels
Initial Directory: $(ProjectDir)\bin\Debug
/wait will stop before closing the console (to analyze output) otherwise use: /out=nunit-test-out.log
/xml will create a result report (usefull for graph geneation)
/labels will label tests in stdout
From now on, you will have two new external tools under TOOLS named NUnit and NUnit-console.
If you click on them, NUnit or Nunit-console will be launched and the current assembly will automatically be loaded.
NUnit (gui) automatically reload assembly when dll is re-built
== EXTERNAL TOOL IN TOOLBAR ============================================
VIEW -> Toolbars -> Customize
Toolbs TAB -> New Toolbar -> Name: "Nunit"
Commands TAB -> Select Toolbar choice -> select "NUnit" toolbar from drop down
-> Add Command -> Category: "Tools" + Commands: "External Command X" (choose the right one)
Now you have the ability to launch it directly from toolbar.
== DEBUG NUNIT GUI =====================================================
1.
On visual studio 2012 add this under nunit.exe.config:
<supportedRuntime version="4.0" />
inside <startup> section
2.
Launch NUnit GUI (i.e. from toolbar shortcut previously added)
3.
Set breakpoint in VS
4.
DEBUG -> Attach to process -> nunit.exe
5.
Run test from GUI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment