views:

881

answers:

8

I want to start using Nunit (finally), I am using Visual Studio 2008.

Is it as simple as importing Nunit into my test project?

I remember seeing a GUI for NUnit, does that do the exact same thing that a separate test project would do, except show you the pass/fail visually?

+1  A: 

Yes, that's basically it. Personally I find the unit test runner which comes with ReSharper to be excellent - and the tool itself is well worth the licence feel. Alternatively there's TestDriven.NET.

Having a test project which runs nunit-gui or nunit-console separately is all very well, but you really want the whole unit testing experience to be as seamless as possible. The easier it is to write and run tests, the more likely you are to do it - which is a very good thing. Don't underestimate the gradual build-up of frustration due to a slightly poorer user experience, flipping between windows etc.

Jon Skeet
+2  A: 

NUnit is something that isn't inside Visual Studio 2008. It does have a console OR a graphical user interface (gui) that can be run both outside VS2008 OR can be attached to the process of VS2008 for debugging.

If you do want something inside VS2008 you need to have a third party pluging like ReSharper.

Edit: This has been answered in the past (not for VS2008 specificly but still relevant)

Daok
A: 

The GUI is nice, but if you run your tests often, you'll probably abandon it for a faster/integrated runner.

In any case, you have some options on how to run your tests:

  • NUnit.Gui.Exe -- you can run this & select your test project dll to run the tests. While it is open it will refresh when you build, so you can ALT-TAB to it & re-run your tets. Another technique I've seen is to set this application as the startup program for your test project. Then set your test project as the startup project and push F5.
  • Download & use TestDriven.net. This is fast and lets you run tests from a right click menu, while you're sitting on a test or at a node in the solution explorer. This is what I use mostly. I have it mapped to CTRL+T for quick access.
  • Resharper has a test runner as well. This gives you the GUI with red/green lights inside of visual studio. It also gives you a little icon next to each of your tests to quickly run them.
Ben Scheirman
JetBrains no longer offers the free ReSharper UnitRun (http://www.jetbrains.com/unitrun/) if that was what you were referring to.
Ray Vega
Thanks, I've removed it. It's a shame they don't offer it anymore.
Ben Scheirman
+1  A: 

I've used TestDriven.NET with VS2005, and it has changed how I develop and test code.

You can run all of the tests on any class, module, project, or solution. You can also run a test in the debugger, which is tremendously useful to diagnose and fix issues when they crop up.

Adam Tegen
Resharper is cool, but I don't use it for the testing stuff. I install TD.NET for testing as it is much better. TestDriven.NET FTW!
Brian Genisio
+3  A: 

I like to add a link to NUnit in my external tools.

Under Tools->External Tools add NUnit

Title: &NUnit
Command: <path to nunit>
Arguments $(ProjectFileName) /run
Initial directory: $(ProjectDir)

After that you can quickly run it by compiling then hitting ctrl-t, n

Noaki
A: 

You can use the plugin NUnitForVS that is available here: http://www.codeplex.com/NUnitForVS

This integrates the test running and results in your VS 2008 IDE. We've been using it for a couple of months and it's working well for us.

A: 

You should also remember that with VS 2008 professional you can use the MS Unit testing tool that was previously only available in the team versions.

Mark
A: 

You can run it as external program, but as for me it is not very nice. I like, when test starts within the VS. So, if you have ReSharpe you can go to Tools -> Options -> Environment -> Keyboard and set the hot key for ReSharper_UnitTest_ContextRun. I set it to Ctrl + t.

Сергій