XNA Creators Club Online

Nunit debugger?

  • 08/05/2007 9:25 In reply to

    Re: Nunit debugger?

    Try creating a fresh project and then add a new class to it containing this code:

    using NUnit.Framework;

    namespace NUnitTest
    {
        [TestFixture]
        public class TestClass
        {
            [Test]
            public void MyTest()
            {
                Assert.AreEqual(4, 4);
            }
        }
    }


    Right-click on the project name in the Solution Explorer, then select 'Add Reference...' Next, select 'nunit.framework' from the list of assemblies. (If you haven't installed NUnit using the installer, then you'll have to go to the 'Browse' tab and navigate to where you unzipped the NUnit package to, then select the framework DLL directly from the bin folder.)

    After you've done this, you should notice that [TestFixture] and [Test] in the above code have been coloured in and the using statement no longer has its red squiggles.

    Now you can build the project. Then open up NUnit (using either the Start Menu entry if you used the installer, or going to nunit.exe in the bin directory if you manually unzipped), and open up your solution file, your project file or your freshly-built EXE from within the GUI program. Press the green arrow to run the single test. Barring any strange quantum effects, it should pass.

    The unfortunate thing about running NUnit with Visual Studio Express is that you can't attach to the NUnit GUI to debug into your unit tests. As noted above, you'll need to install TestDriven.NET or another add-in to get this functionality. TestDriven.NET is available for free - but for personal use only - here: http://www.testdriven.net/download_release.aspx?LicenceType=Personal

    Hopefully Microsoft will integrate some of their unit testing tools (from VS Team System) in a future release, as it's excellent programming practice. A profiler would be damn useful too.
View Complete Thread