Click here to Skip to main content
12,549,003 members (49,426 online)
Click here to Skip to main content
Add your own
alternative version


43 bookmarked

Easy Debugging of NUnit Tests from Visual Studio 2008 Professional

, 23 Jun 2009 Apache
Rate this:
Please Sign up or sign in to vote.
How to easily debug NUnit tests in Visual Studio 2008 professional edition


This article describes a convenient way of debugging NUnit tests using open source plugin to Visual Studio 2008. Many open source and cross platform projects choose NUnit testing framework for mono and nant support.


Visual Nunit plugin for Visual Studio 2008 was developed to speed up development of MXP protocol reference implementation. Being able to debug unit tests easily from integrated development environment is a big efficiency factor.


  1. Download the latest release from here.
  2. Run the installer.
  3. Start Visual Studio 2008.
  4. Select from Menu View->Other Windows->NUnit View.
  5. Place the view to location of your choice.

Debugging Process

The debugging with Visual Nunit is achieved by simply double clicking the test at NUnit View. To create test cases to your project, do the following steps:

  1. Download NUnit 2.5 from here.
  2. Add nunit.framework.dll to your projects references.
  3. Add test case to the project (See example below).
  4. Make sure your project dependencies have copy local properties set.
  5. Build the project.
  6. To start debugging, click the arrow button of a test row in the NUnit View.
  7. Proceed as normal with Visual Studio Debugging.

Stopping debug will terminate the nunit runner process if your unit test is hanging or if you do not wish to wait until it is completed.

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Diagnostics;
using System.Threading;

namespace NunitTests
    public class ExampleTestFixture
        public void TestSuccess()
            Trace.TraceInformation("Test trace.");

        public void TestException()
            throw new Exception("Test Exception");

        public void TestAssert()
            Assert.Fail("Test Assert");

        public void TestHang()

Points of Interest

Visual Nunit was written with Microsoft Visual Studio 2008 SDK. The project type is Visual Studio Integration Package and the sources are available as open source project from here.


  • 21st June 2009 - Initial version


This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


About the Author

Tommi Laukkanen
Finland Finland
Web and rich client solutions since 2002 with .NET and Java.

Open source contributor to Visual Nunit, OpenSimulator, MXP protocol and IdealistViewer.

You may also be interested in...


Comments and Discussions

Questioncan't step through code Pin
gary-s14-Apr-12 9:55
membergary-s14-Apr-12 9:55 
QuestionRe: can't step through code Pin
Andreas Gieriet26-Dec-12 12:20
memberAndreas Gieriet26-Dec-12 12:20 
QuestionVery nice tool! just one question Pin
paul.vencill5-May-11 5:34
memberpaul.vencill5-May-11 5:34 
Generalvisual NUnit can't find unit tests Pin
x-coder200710-Jan-11 1:09
memberx-coder200710-Jan-11 1:09 
GeneralCan't run tests - please help Pin
bszom28-Oct-10 5:40
memberbszom28-Oct-10 5:40 
Hi Tommi,

When I try to run my tests through the Visual Nunit window they instantly fail. Here are the exception details:

Failure: System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> System.NullReferenceException : Object reference not set to an instance of an object.

Stack Trace:
System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType)
System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
NUnit.Core.Reflect.Construct(Type type)
NUnit.Core.TestMethod.Run(TestResult testResult)

This is with Visual Studio 2010 Pro, NUnit 2.5.8, Visual Nunit 1.1.7 (as reported by VS Extension Manager, which is how I installed it - your SourceForge page lists the latest version as 1.1.3 while the download button on the summary page links to 1.0.3 ???)

The references for my test project (that's also the project type) are all set to copy local, except for all of the refs to the System namespace and Microsoft.VisualStudio.QualityTools.UnitTestFramework. I've tried setting copy local to true on Microsoft.VisualStudio.QualityTools.UnitTestFramework, without success. nunit.framework.dll is definitely being copied.

How can I figure out what's going wrong?
GeneralRe: Can't run tests - please help Pin
naughton8-Aug-12 14:28
membernaughton8-Aug-12 14:28 
GeneralVisual Nunit 2010 1.1.7 Released Pin
Tommi Laukkanen9-Oct-10 21:55
memberTommi Laukkanen9-Oct-10 21:55 
GeneralRe: Visual Nunit 2010 1.1.7 Released Pin
Scythal31-Dec-10 5:41
memberScythal31-Dec-10 5:41 
GeneralStopping at breakpoints Pin
Member 292366017-Aug-10 15:14
memberMember 292366017-Aug-10 15:14 
GeneralRe: Stopping at breakpoints Pin
Tommi Laukkanen9-Oct-10 21:53
memberTommi Laukkanen9-Oct-10 21:53 
GeneralDebugging of NUnit tests:VS 2010, Visual NUnit and project's config file Pin
levenyu16-Aug-10 12:02
memberlevenyu16-Aug-10 12:02 
GeneralRe: Debugging of NUnit tests:VS 2010, Visual NUnit and project's config file Pin
SRM196929-Sep-10 17:45
memberSRM196929-Sep-10 17:45 
GeneralRe: Debugging of NUnit tests:VS 2010, Visual NUnit and project's config file Pin
Tommi Laukkanen29-Sep-10 18:18
memberTommi Laukkanen29-Sep-10 18:18 
QuestionCould you make a VS 2010 version please? Pin
Omar Al Zabir5-May-10 5:12
mvpOmar Al Zabir5-May-10 5:12 
AnswerRe: Could you make a VS 2010 version please? Pin
Tommi Laukkanen5-May-10 5:47
memberTommi Laukkanen5-May-10 5:47 
GeneralVisual Nunit 2010 1.1 and Visual Nunit 2008 1.0.2 released Pin
Tommi Laukkanen19-Dec-09 4:20
memberTommi Laukkanen19-Dec-09 4:20 
QuestionTests not showing up? Pin
Bernard O'Flynn26-Nov-09 23:36
memberBernard O'Flynn26-Nov-09 23:36 
AnswerRe: Tests not showing up? Pin
Dan Neely7-Jan-10 5:18
memberDan Neely7-Jan-10 5:18 
AnswerRe: Tests not showing up? Pin
jfh1089-Jan-10 7:13
memberjfh1089-Jan-10 7:13 
AnswerRe: Tests not showing up? Pin
om29721-Jan-10 23:59
memberom29721-Jan-10 23:59 
GeneralBeta Release of Visual Nunit support for Visual Studio 2010 Pin
Tommi Laukkanen6-Nov-09 17:21
memberTommi Laukkanen6-Nov-09 17:21 
GeneralVisual Nunit 1.0.1 Released Pin
Tommi Laukkanen1-Nov-09 6:53
memberTommi Laukkanen1-Nov-09 6:53 
GeneralVisual Nunit Runner stopped working Pin
tomasz pr.30-Jul-09 1:26
membertomasz pr.30-Jul-09 1:26 
GeneralRe: Visual Nunit Runner stopped working Pin
Tommi Laukkanen30-Jul-09 20:11
memberTommi Laukkanen30-Jul-09 20:11 
GeneralRe: Visual Nunit Runner stopped working Pin
tomasz pr.30-Jul-09 21:56
membertomasz pr.30-Jul-09 21:56 
GeneralRe: Visual Nunit Runner stopped working Pin
Tommi Laukkanen31-Jul-09 0:04
memberTommi Laukkanen31-Jul-09 0:04 
GeneralRe: Visual Nunit Runner stopped working Pin
tomasz pr.31-Jul-09 0:23
membertomasz pr.31-Jul-09 0:23 
GeneralRe: Visual Nunit Runner stopped working Pin
Tommi Laukkanen7-Aug-09 5:04
memberTommi Laukkanen7-Aug-09 5:04 
GeneralRe: Visual Nunit Runner stopped working Pin
daveevans27-Aug-09 0:56
memberdaveevans27-Aug-09 0:56 
GeneralGreat for Debugging, Bad for Testing Pin
Joseph DeMilo13-Jul-09 11:16
memberJoseph DeMilo13-Jul-09 11:16 
GeneralRe: Great for Debugging, Bad for Testing Pin
Tommi Laukkanen15-Jul-09 2:02
memberTommi Laukkanen15-Jul-09 2:02 
QuestionVisual Studio 2005 version? Pin
Kevin Skinner6-Jul-09 5:16
memberKevin Skinner6-Jul-09 5:16 
AnswerRe: Visual Studio 2005 version? Pin
Tommi Laukkanen6-Jul-09 5:33
memberTommi Laukkanen6-Jul-09 5:33 
GeneralVisual Nunit 1.0 RC 1 Released Pin
Tommi Laukkanen3-Jul-09 7:55
memberTommi Laukkanen3-Jul-09 7:55 
GeneralRe: Visual Nunit 1.0 RC 1 Released Pin
Tommi Laukkanen3-Jul-09 10:20
memberTommi Laukkanen3-Jul-09 10:20 
GeneralRe: Visual Nunit 1.0 RC 1 Released [modified] Pin
gtmxxl5-Jul-09 22:32
membergtmxxl5-Jul-09 22:32 
GeneralRe: Visual Nunit 1.0 RC 1 Released [modified] Pin
Tommi Laukkanen6-Jul-09 3:23
memberTommi Laukkanen6-Jul-09 3:23 
QuestionVisual Studio 2005? Pin
DrMcClelland2-Jul-09 5:02
memberDrMcClelland2-Jul-09 5:02 
AnswerRe: Visual Studio 2005? Pin
Tommi Laukkanen2-Jul-09 9:13
memberTommi Laukkanen2-Jul-09 9:13 
GeneralRe: Visual Studio 2005? Pin
gtmxxl3-Jul-09 0:36
membergtmxxl3-Jul-09 0:36 
GeneralRe: Visual Studio 2005? Pin
Tommi Laukkanen3-Jul-09 7:56
memberTommi Laukkanen3-Jul-09 7:56 
GeneralCrash Pin
gtmxxl2-Jul-09 4:07
membergtmxxl2-Jul-09 4:07 
GeneralRe: Crash Pin
Tommi Laukkanen2-Jul-09 9:14
memberTommi Laukkanen2-Jul-09 9:14 
GeneralMy vote of 1 Pin
JRASPEN29-Jun-09 19:27
memberJRASPEN29-Jun-09 19:27 
GeneralCrash When loading Pin
JRASPEN24-Jun-09 11:09
memberJRASPEN24-Jun-09 11:09 
GeneralRe: Crash When loading Pin
Tommi Laukkanen1-Jul-09 19:06
memberTommi Laukkanen1-Jul-09 19:06 
GeneralRe: Crash When loading Pin
Tommi Laukkanen1-Jul-09 19:44
memberTommi Laukkanen1-Jul-09 19:44 
GeneralVersion 0.9 Released Pin
Tommi Laukkanen23-Jun-09 20:35
memberTommi Laukkanen23-Jun-09 20:35 
GeneralVS Standard Edition Pin
Daniel M. Camenzind22-Jun-09 20:01
memberDaniel M. Camenzind22-Jun-09 20:01 
GeneralRe: VS Standard Edition Pin
Tommi Laukkanen22-Jun-09 20:20
memberTommi Laukkanen22-Jun-09 20:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 24 Jun 2009
Article Copyright 2009 by Tommi Laukkanen
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid