Click here to Skip to main content
Licence Apache
First Posted 22 Jun 2009
Views 61,466
Bookmarked 35 times

Easy Debugging of NUnit Tests from Visual Studio 2008 Professional

By Tommi Laukkanen | 23 Jun 2009
How to easily debug NUnit tests in Visual Studio 2008 professional edition
1 vote, 14.3%
1

2
1 vote, 14.3%
3

4
5 votes, 71.4%
5
4.00/5 - 7 votes
μ 4.00, σa 2.75 [?]

Introduction

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.

Background

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.

Installation

  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
{
    [TestFixture]
    public class ExampleTestFixture
    {
        [Test]
        public void TestSuccess()
        {
            Trace.TraceInformation("Test trace.");
        }

        [Test]
        public void TestException()
        {
            throw new Exception("Test Exception");
        }

        [Test]
        public void TestAssert()
        {
            Assert.Fail("Test Assert");
        }

        [Test]
        public void TestHang()
        {
            Thread.Sleep(10000);
        }
    }
}

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.

History

  • 21st June 2009 - Initial version

License

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

About the Author

Tommi Laukkanen

Architect

Finland Finland

Member
Web and rich client solutions since 2002 with .NET and Java.
 
Open source contributor to Visual Nunit, OpenSimulator, MXP protocol and IdealistViewer.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionVery nice tool! just one question Pinmemberpaul.vencill6:34 5 May '11  
Generalvisual NUnit can't find unit tests Pinmemberx-coder20072:09 10 Jan '11  
GeneralCan't run tests - please help Pinmemberbszom6:40 28 Oct '10  
GeneralVisual Nunit 2010 1.1.7 Released PinmemberTommi Laukkanen22:55 9 Oct '10  
GeneralRe: Visual Nunit 2010 1.1.7 Released PinmemberScythal6:41 31 Dec '10  
GeneralStopping at breakpoints PinmemberMember 292366016:14 17 Aug '10  
GeneralRe: Stopping at breakpoints PinmemberTommi Laukkanen22:53 9 Oct '10  
GeneralDebugging of NUnit tests:VS 2010, Visual NUnit and project's config file Pinmemberlevenyu13:02 16 Aug '10  
GeneralRe: Debugging of NUnit tests:VS 2010, Visual NUnit and project's config file PinmemberSRM196918:45 29 Sep '10  
GeneralRe: Debugging of NUnit tests:VS 2010, Visual NUnit and project's config file PinmemberTommi Laukkanen19:18 29 Sep '10  
QuestionCould you make a VS 2010 version please? PinmvpOmar Al Zabir6:12 5 May '10  
AnswerRe: Could you make a VS 2010 version please? PinmemberTommi Laukkanen6:47 5 May '10  
GeneralVisual Nunit 2010 1.1 and Visual Nunit 2008 1.0.2 released PinmemberTommi Laukkanen5:20 19 Dec '09  
QuestionTests not showing up? PinmemberBernard O'Flynn0:36 27 Nov '09  
AnswerRe: Tests not showing up? PinmemberDan Neely6:18 7 Jan '10  
AnswerRe: Tests not showing up? Pinmemberjfh1088:13 9 Jan '10  
AnswerRe: Tests not showing up? Pinmemberom2970:59 22 Jan '10  
GeneralBeta Release of Visual Nunit support for Visual Studio 2010 PinmemberTommi Laukkanen18:21 6 Nov '09  
GeneralVisual Nunit 1.0.1 Released PinmemberTommi Laukkanen7:53 1 Nov '09  
GeneralVisual Nunit Runner stopped working Pinmembertomasz pr.2:26 30 Jul '09  
GeneralRe: Visual Nunit Runner stopped working PinmemberTommi Laukkanen21:11 30 Jul '09  
GeneralRe: Visual Nunit Runner stopped working Pinmembertomasz pr.22:56 30 Jul '09  
GeneralRe: Visual Nunit Runner stopped working PinmemberTommi Laukkanen1:04 31 Jul '09  
GeneralRe: Visual Nunit Runner stopped working Pinmembertomasz pr.1:23 31 Jul '09  
GeneralRe: Visual Nunit Runner stopped working PinmemberTommi Laukkanen6:04 7 Aug '09  

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

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

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