NUnit and Visual Studio

Like all my “What I learned” experiences, this may not sound like much to you, but it was interesting to me.

I attended a PhillyDotNet hands on lab session tonight  presented by Brian Donahue.  The lab was an avalance of Model View Presenter, Domain Driven Development, and unit testing techniques, with software tools such as Resharper, NUnit, and Rhino Mocks thrown in for good measure.  It was a lot to comprehend, but I managed to stumble along a few steps behind throughout. 

Here are some of the tidbits I learned:

  • You don’t have to have NUnit or Rhino installed on your computer.  The dlls were included with the sample project Brian handed out at the beginning.  Having those, I could reference them in my code, although I could not actually run the NUnit tests.  But the code compiled.
  • It was pretty easy to convert the NUnit tests over to the built-in Visual Studio unit tester – add the right reference and change [TextFixture], [Test], and [Setup] attirbutes to [TestClass], [TestMethod], and [TestInitialize()].  These are the only features of NUnit I knew to start with, and the VS tester seems to be pretty equivalent to use.
  • What I did not figure out was how to convert an NUnit testing project into a VS test project.  I mean, what properties or attributes designated it as a test project?  I ended up having to copy the .cs files from the NUnit test to the VS test project.  My questions here are:  What “type” of project was the original test project as created by Brian, and what designated the test project as something that VS recognized?

There you have it.


One Comment

  1. Posted July 30, 2008 at 11:16 am | Permalink

    Hi there,

    Don’t see your name on your blog, so I’m not sure who I’m speaking to, but thanks for coming out last night! I learned a lot, and am hoping to improve my approach and reduce the “avalanche” effect you’re talking about. I got a lot of great feedback on how to do so, and will incorporate that in two months when I do another workshop with Philly.NET

    I don’t know much about using VS Test vs NUnit, but I can tell you that the test project in my solution was simply a class library with test fixtures included in it. NUnit, TestDriven.NET, and Resharper all recognize the [TestFixture] and other test-related attributes and run the tests within that DLL. Installing any one of those tools will enable you to run the tests.

    Typically, I include the entire NUnit bin folder in my source directory, including the GUI and console runner but neglected to do that this time. Having those gives everyone the ability to run the tests without installing via the installer. The idea behind having all your tools and dependencies in your source directory is that anyone can check out the trunk and get up and running (and running tests) without needing to do any external setup or installation.

    I posted my code and slides here:

    And am thinking about doing a follow up at a Philly ALT.NET meeting if anyone is interested in getting more questions answered, and seeing more of the finished app. Keep an eye on my blog, or even better, join our discussion group and ask questions, and get announcements about meetings:

    Thanks again for coming, and thanks for the feedback!!

Post a Comment

Required fields are marked *

%d bloggers like this: